Error using mtimes Inner matrix dimensions must agree !!
1 view (last 30 days)
Show older comments
hi hope anyone can help me "Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> Untitled at 28 y(t)=teta'*phi(:,t);" the code
- clear all
- close all
- clc
- N=1700;
- i=1:N;
- u(i)=sin(0.1*i)+sin(0.2*i)+sin(0.3*i)+sin(0.4*i)+sin(i)+sin(2*i)+sin(3*i)+sin(4*i);
- % identification
- %y(t)=-a1y(t-1)-b1y(t-2)+c1u(t-1)
- a1=0.5;b1=0.45;c1=0.8;
- teta0=zeros(N,3);
- %teta0=zeros(3,3);
- F(1)=0.01;
- F=zeros(1,N);
- %phi0=[0 0 0];
- y0(1)=0;
- a0=0;
- b0=0;
- c0=0;
- y(1)=0;
- y(2)=0;
- y0(2)=0;
- F(1)=0;
- for t=3:N ;
- phi(:,t)=[-y(t-1) -y(t-2) u(t-1)];
- phi0(:,t)=[y0(t-1) -y0(t-2) u(t-1)]';
- teta=[a1 b1 c1];
- y(t)=teta'*phi(:,t);
- y0(t)=teta0(t-1,:)'*phi(:,t);
- e(t)=y(t)-y0(t);
- teta0(t,:)=teta0(t-1,:)+(F(t-1)*phi(:,t)*e(t))'/(1+phi(:,t)'*F(t-1)*phi(:,t));
- F(t)=F(t-1)-((F(t-1)*phi(:,t-1)*phi(:,t-1)'*F(t-1))/(1+phi(:,t-1)'*F(t-1)*phi(:,t-1)'));
- end ;
- teta0(N,:)
2 Comments
Star Strider
on 17 May 2016
Norton Antivirus identifies your upload site as a know dangerouw website, and blocks it.
Use the brown-framed green landscape picture icon instead to upload it here.
the cyclist
on 17 May 2016
Also, please upload code, not a screenshot of code (which we cannot copy & paste and run if we want to).
Answers (2)
Elias Gule
on 17 May 2016
Are you doing elementwise multiplication? If so, then replace the '*' operator with '.*' operator, Such that
phi0(:,t)=[y0(t-1) -y0(t-2)*u(t-1)]';
changes to
phi0(:,t)=[y0(t-1) -y0(t-2).*u(t-1)]';
0 Comments
Star Strider
on 17 May 2016
You had several errors that I discovered. Changing lines 28, 29 and 32 to:
y(t)=teta*phi(:,t);
y0(t)=teta0(t-1,:)*phi(:,t);
. . .
F(t)=F(t-1)-((F(t-1)*phi(:,t-1)'*phi(:,t-1)*F(t-1))/(1+phi(:,t-1)'*F(t-1)*phi(:,t-1)));
will do the matrix calculations without throwing any errors, and producing scalar results, as your scalar assignments require.
I leave it to you to determine if it gives the correct results.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!