Error using ==> mtimes Inner matrix dimensions must agree.
古いコメントを表示
when I run the main code that contain the execution of the function (StateEq.m) , and Xi is a matrix with (StateDim,nCpts) dimensions contains state space column vectors
StateDim = 8;
nCpts = 2*StateDim ;
Xp = StateEq(Xi);
I get
Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> StateEq at 24
X(:,k) = Xa(:,k) + dt*X1;
someone could help me. This is my StateEq function code:
function X=StateEq(Xa)
global StateDim nCpts dt ae ke ai ki c d gama e ks T0 T a ue ui
X=zeros(StateDim,nCpts);
for k=1:nCpts
Ti = 1/(T0+T);
x0 = 1/(1+exp(-c*(1-d)));
xt = 1/(1+exp(-c*(Xa(1,k)-d)));
me = ((2-xt)/(2-x0))*Xa(1,k);
mi = Xa(3,k);
m = ((gama*me)+mi)/(gama+1);
X1=[Xa(2,k);
((ae*ke*(ue-1))-(2*ke*Xa(2,k))-((ke^2)*(Xa(1,k)-1)));
Xa(4,k);
((ai*ki*(ui-1))-(2*ki*Xa(4,k))-((ki^2)*(Xa(3,k)-1)));
Xa(6,k);
((e*(ue-1))-(2*ks*Xa(6,k))-((ks^2)*(Xa(5,k)-1)));
Ti*(Xa(5,k)-(Xa(7,k)^(1/a)));
(1/T0)*(m-(Ti*((T0*(Xa(7,k)^(1/a)))+(T*Xa(5,k)))*(Xa(8,k)/Xa(7,k))))];
X(:,k) = Xa(:,k) + dt*X1;
end
Knowing that
dt ae ke ai ki c d gama e ks T0 T a ue ui
are simple parameters
another thing is that when i try to execute the content of the StateEq in the command window (i create an experimental matrix Xi and execute the content of the function for k=1 it work fine)
2 件のコメント
KSSV
2016 年 10 月 1 日
Check the size of Xa(:,k), X1. I think they are of different size that's why error popping out.
David Goodmanson
2016 年 10 月 1 日
Looks like it's telling you that dt is not a scalar and that the number of columns of dt ~= the number of rows of X1.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!