Skip to content

Instantly share code, notes, and snippets.

@YoshiRi
Created June 30, 2016 08:59
Show Gist options
  • Save YoshiRi/87fadfd20f94cdcfde17fa25ac44691b to your computer and use it in GitHub Desktop.
Save YoshiRi/87fadfd20f94cdcfde17fa25ac44691b to your computer and use it in GitHub Desktop.
RLS function for MATLAB
function [Cta, Pn, Rn] = rls_const_func(Cta_,Pn_,Rn_,Yn ,Zn)
%% forgetting factor (Time varying)
Rn = (1 - 0.01)*Rn_ + 0.01;
%% function
Num = Rn+Zn'*Pn_*Zn;
Pn = 1/Rn*( Pn_ - (Pn_ * Zn * Zn' * Pn_/Num) );
Ln = Pn_*Zn /Num;
En = Yn - Zn.' * Cta_;
%% Output
Cta = Cta_ + Ln * En;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment