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 ==> mtimesInner matrix dimensions must agree.Error in ==> StateEq at 24X(:,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 uiX=zeros(StateDim,nCpts);for k=1:nCptsTi = 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)
Best Answer