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 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