フィルターのクリア

i want to plot x and y for ODE45 function

1 回表示 (過去 30 日間)
Mustafa Alhandhali
Mustafa Alhandhali 2019 年 4 月 17 日
コメント済み: Mustafa Alhandhali 2019 年 4 月 17 日
i have this function
function dy = Funcion(x,y)
m=0.1; M=10;c=0.1; k=0.4; F=5*x;
dy = zeros(2,1);
dy(1) = x(2);
dy(2) = -(c*y(1) - F + k*y(2))/(M + m);
and i want to plot x and y i write
[x,y] = ode45(@Funcion,[0 10],[0.1 -1]);
plot(x,y)
this error is appear why
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

採用された回答

James Tursa
James Tursa 2019 年 4 月 17 日
This line doesn't look correct:
dy(1) = x(2);
The first agument x in the derivative function is the independent variable and a scalar, so there is no x(2) value. Maybe you meant this:
dy(1) = y(2);

その他の回答 (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