Error using mtimes Inner matrix dimensions must agree !!

조회 수: 1 (최근 30일)
smail dahmani
smail dahmani 2016년 5월 17일
답변: Star Strider 2016년 5월 17일
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
Star Strider
Star Strider 2016년 5월 17일
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
the cyclist 2016년 5월 17일
Also, please upload code, not a screenshot of code (which we cannot copy & paste and run if we want to).

댓글을 달려면 로그인하십시오.

답변 (2개)

Elias Gule
Elias Gule 2016년 5월 17일
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)]';

Star Strider
Star Strider 2016년 5월 17일
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.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by