Borrar filtros
Borrar filtros

How to solve "Subscripted assignment dimension mismatch"?

1 visualización (últimos 30 días)
ZHUOREN XU
ZHUOREN XU el 28 de Mzo. de 2017
Respondida: Santhana Raj el 31 de Mzo. de 2017
tspan=[0 3]; % time span
X0=[0.0 0.0 10 0 0 0]'; % initial postitions/angles and derivatives thereof Angular_velocity=00:10:400;%rotor_speed*2*pi/60; % in rad/sec PAR0=[Angular_velocity]; %omega
for i=1:10(Angular_velocity)
%run ode45 refering to the function dXdt
options = odeset('RelTol',1e-2,'AbsTol',1e-2);
options = odeset(options,'OutputFcn',@odeplot,'OutputSel',[1 2 3]);
[t,X(:,:,i)]= ode23(@mymodel_working,tspan,X0,options,PAR0);
end
%break X matrix down into column vectors of changing values with t
x1(:,i)=X(:,1);
x2(:,i)=X(:,2);
x3(:,i)=X(:,3);
x4(:,i)=X(:,4);
x5(:,i)=X(:,5);
x6(:,i)=X(:,6);
% x7=X(:,7);
figure plot(t,x3,'-b')

Respuestas (1)

Santhana Raj
Santhana Raj el 31 de Mzo. de 2017
I see that the X is a 3dimentional matrix. And in the code where you split it up into multiple x, you are accessing X as a 2D matrix.
I assume this is the problem. If so, then change the lines to :
x1=X(:,:,1);
Note that now x1 is a 2D matrix and not a column matrix. The index i is not required as anyway you are outside the loop and the value of i is fixed to 10;
I also would like to point to you that the ODE is running 10 times without any change in its input. it is gonna give the same result.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by