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;

采纳的回答

Torsten
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 CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by