ODE45 Code Issue

조회 수: 14 (최근 30일)
Ryan Bingaman
Ryan Bingaman 2020년 3월 5일
댓글: Star Strider 2020년 3월 5일
Any help would be greatly appreciated on this code! The error messages are located beneath the code.
[T,X] = ode45(@(t,x) ode45for3B(t,x), [0,10], [0,0]);
function [xdot] = ode45for3B(t,x)
xdot = [0;0;0;0];
xdot(1) = x(2);
xdot(2) = (-5.667).*x(1) - (1.333333).*x(2) + (3.667).*x(3) + (1.333333).*x(4);
xdot(3) = x(4);
xdot(4) = (2.5).*x(1) + (0.9091).*x(2) - (2.5).*x(3) - (0.9091).*x(4) + (4.5454);
end
Index exceeds the number of array elements (2).
Error in ME357_HW6_3B>ode45for3B (line 15)
xdot(2) = (-5.667).*x(1) - (1.333333).*x(2) + (3.667).*x(3) + (1.333333).*x(4);
Error in ME357_HW6_3B>@(t,x)ode45for3B(t,x) (line 10)
[T,X] = ode45(@(t,x) ode45for3B(t,x), [0,10], [0,0]);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in ME357_HW6_3B (line 10)
[T,X] = ode45(@(t,x) ode45for3B(t,x), [0,10], [0,0]);

답변 (1개)

Star Strider
Star Strider 2020년 3월 5일
Four differential equations require four initial conditions.
[T,X] = ode45(@(t,x) ode45for3B(t,x), [0,10], [0,0]);
↑ ← HERE
there are only two.
  댓글 수: 2
Ryan Bingaman
Ryan Bingaman 2020년 3월 5일
Can't believe it was something that simple that I missed. Thank you!!
Star Strider
Star Strider 2020년 3월 5일
My pleasure!
If my Answer helped you solve your problem, please Accept it!

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by