Unable to perform assignment

조회 수: 3 (최근 30일)
Samson
Samson 2019년 6월 28일
편집: Jan 2019년 6월 28일
From my attached code and get the following error
Unable to perform assignment because the left and right sides have a different number of elements.
Error in aa1 (line 12)
*Y(i)yo=utput;
a= 0.2; b= 0.2; c = 5.7;
% initial condition
yo = [0.5;0.5;1];
% computing the trajectory
dt = 0.01;
tspan = (dt:dt:100);
yinput = yo;
Y = zeros(tspan(end)/dt,1);
for i = 1: tspan(end)/dt
time = i*dt;
youtput = rk4angelstepb(@rosslerb,dt,yinput,a,b,c);
Y(i) = youtput;
yinput = youtput;
end
  댓글 수: 1
Adam
Adam 2019년 6월 28일
You can see what size things are with a breakpoint, or using the stop on errors option and testing on command line when it stops. It's a valuable resource for finding these problems. How you solve them is very situation dependent, but the error message says what is wrong and what is expected in this case.

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

채택된 답변

Jan
Jan 2019년 6월 28일
편집: Jan 2019년 6월 28일
If the initial condition has 3 elements: yo = [0.5;0.5;1], te evaluated trajectory will have 3 elements per time step also. Then you need most likely:
Y = zeros(3, tspan(end)/dt);
for i = 1: tspan(end)/dt
time = i*dt;
youtput = rk4angelstepb(@rosslerb,dt,yinput,a,b,c);
Y(:, i) = youtput;
...

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by