can anyone help me to get rid of the error not enough input arguments in line 7?
2 次查看(过去 30 天)
显示 更早的评论
m = 2;
c = 0.4;
k = 4;
x0 = [10; 0];
Time_Span = [0, 40.0];
xdot = zeros(2,1);
xdot(1) = x(2);
xdot(2) = -(1/m)*(c*x(2) + k*x(1));
[t_ex2, x_ex2] = ode45(@ODE_Damped_Spring, Time_Span, x0);
figure;
plot(t_ex2, x_ex2(:,1), 'o-')
title('ode45 Position for Damped Spring')
grid on;
0 个评论
采纳的回答
Torsten
2024-1-18
x0 = [10; 0];
Time_Span = [0, 40.0];
[t_ex2, x_ex2] = ode45(@ODE_Damped_Spring, Time_Span, x0);
figure;
plot(t_ex2, x_ex2(:,1), 'o-')
title('ode45 Position for Damped Spring')
grid on
function xdot = ODE_Damped_Spring(t,x)
m = 2;
c = 0.4;
k = 4;
xdot = zeros(2,1);
xdot(1) = x(2);
xdot(2) = -(1/m)*(c*x(2) + k*x(1));
end
更多回答(0 个)
另请参阅
类别
在 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!