can anyone help me to get rid of the error not enough input arguments in line 7?

2 ビュー (過去 30 日間)
Puja
Puja 2024 年 1 月 18 日
コメント済み: Puja 2024 年 1 月 18 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by