필터 지우기
필터 지우기

How to solve "Subscripted assignment dimension mismatch"?

조회 수: 1 (최근 30일)
ZHUOREN XU
ZHUOREN XU 2017년 3월 28일
답변: Santhana Raj 2017년 3월 31일
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')

답변 (1개)

Santhana Raj
Santhana Raj 2017년 3월 31일
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.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by