% Implement Fibonacci sequence by using a for loop clear all close all clc u_1=1; u_2=1; u_v=[u_1 u_2]; % start to compute the recursive relation at time k=3 k=3; tk_f=9; % final time for idx_k=k:tk_f u_k=u_v(idx_k-1)+u_v(idx_k-2); % recursive relation u_v_old=u_v; u_v=[u_v_old u_k]; end % define time time_k=1:tk_f; % time vector % plot the sequence figure plot (time_k,u_v,'ob','MarkerSize',8,'LineWidth',3) xlabel('time k') ylabel('u_k') set(gca,'FontSize',16) grid on