RLS algorithm Implementation problem
조회 수: 14 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!