RLS algorithm Implementation problem

9 ビュー (過去 30 日間)
Ambarish
Ambarish 2014 年 3 月 5 日
回答済み: mohd albahrani 2017 年 11 月 18 日
Hello I was trying to implement the Recursive Least square Algorithm normally instead of using the System Identification Tool Box.But consistently getting few error.Please let me know what are the best methods to solve it .
y(2)=2; y(3)=4; y(4)=5; x = rand(1,100) plot(x) title('input') for n=5:1:100 y(n)=1.98*y(n-1)-1.284*y(n-2)+0.272*y(n-3)+4*x(n-1)+6*x(n-2)+8*x(n-3); end; figure plot(y) title('cleaned')
for i=5:1:100; phi(i,:)=[ -y(i-1) -y(i-2) -y(i-3) x(i-1) x(i-2) x(i-3) ]; end; theta = (phi'* phi)\phi'*y';
for n=2:1:100 e(n,:)=y(n)-phi'*theta(n-1,:) p(n,:)= p(n-1)-[p(n-1,:)*phi*phi'*p(n-1,:)]/[ 1+phi'*p(n-1,:)*phi] k(n,:)=p(n,:)*phi theta(n,:)= theta(n,:)+k(n)*e(n) end
when I run the last for loop it says that
'Subscripted assignment dimension mismatch'.
Thanks in advance

回答 (1 件)

mohd albahrani
mohd albahrani 2017 年 11 月 18 日
y(2)=2; y(3)=4; y(4)=5; x = rand(1,100); plot(x); title('input') for n=5:1:100 y(n)=1.98*y(n-1)-1.284*y(n-2)+0.272*y(n-3)+4*x(n-1)+6*x(n-2)+8*x(n-3); end;
figure plot(y) title('cleaned')
for i=5:1:100; phi(i,:)=[ -y(i-1) -y(i-2) -y(i-3) x(i-1) x(i-2) x(i-3) ]; end; theta = (phi'* phi)\phi'*y'; (This is not correct as y vector not scalier and not sure of the equation)
for n=2:1:100 e(n,:)=y(n)-phi'*theta(n-1,:) (looks correct) p(n,:)= p(n-1)-[p(n-1,:)*phi*phi'*p(n-1,:)]/[ 1+phi'*p(n-1,:)*phi] (Not correct Equation) k(n,:)=p(n,:)*phi (correct) theta(n,:)= theta(n,:)+k(n)*e(n) (Correct) end;
you need to review the theory well then try to apply the equations with taking care of the vectors dimensions as well.
all the best

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by