i want to plot x and y for ODE45 function

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by