RLS algorithm Implementation problem

7 visualizzazioni (ultimi 30 giorni)
Ambarish
Ambarish il 5 Mar 2014
Risposto: mohd albahrani il 18 Nov 2017
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

Risposte (1)

mohd albahrani
mohd albahrani il 18 Nov 2017
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

Categorie

Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by