ODE45 Code Issue
조회 수: 14 (최근 30일)
이전 댓글 표시
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]);
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!