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!