i want to plot x and y for ODE45 function
1 次查看(过去 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, ...
0 个评论
采纳的回答
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 Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!