%%% %%% Example of parameter on-line estimation %%% with RLS and forgetting factor %%% close all, clc n = 3; % Model order lambda = 0.70; % Forgetting factor [theta_hat,y_hat] = rlsff([Y U],n,lambda); % Recursive least squares with forgetting factor figure, plot(t,Y,'-',t,y_hat,'--',... t,1.2*ones(size(Y))*max(Y(1:499)),':',... t,1.2*ones(size(Y))*min(Y(1:499)),':') xlabel('Time (s)'), ylabel('y(k)'), title('Measured (-) and predicted (--) output') legend('Measured output','Predicted output') figure, subplot(131), plot(t,theta_hat(1,:)) xlabel('Time (s)'), title('Parameter \alpha_3') subplot(132), plot(t,theta_hat(2,:)) xlabel('Time (s)'), title('Parameter \alpha_2') subplot(133), plot(t,theta_hat(3,:)) xlabel('Time (s)'), title('Parameter \alpha_1')