Created
July 8, 2016 11:04
-
-
Save YoshiRi/79f78611ec8a81f78009d43d0869fe90 to your computer and use it in GitHub Desktop.
RLS Program for MATLAB Estimating one Parameter from single input and output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Theta_est = rls_single_func(Yn ,Zn) | |
%% forgetting factor (Time varying) | |
persistent Rn ; | |
if isempty(Rn) | |
Rn = 0.95; | |
end | |
Rn = (1 - 0.01)*Rn + 0.01; | |
%% Covariance Mat and Estimated val | |
persistent Pn; | |
persistent Cta; | |
if isempty(Pn) | |
Pn = 1000; | |
end | |
if isempty(Cta) | |
Cta = 0; | |
end | |
%% function | |
Num = Rn+Zn'*Pn*Zn; | |
Ln = Pn*Zn /Num; | |
En = Yn - Zn.' * Cta; | |
%% Update covariance Mat | |
Pn = 1/Rn*( Pn - (Pn * Zn * Zn' * Pn/Num) ); | |
%% Output | |
Cta = Cta + Ln * En; | |
Theta_est = Cta; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment