필터 지우기
필터 지우기

System of nonlinear differential equations

조회 수: 2 (최근 30일)
Aleem Andrew
Aleem Andrew 2020년 2월 4일
답변: Walter Roberson 2020년 2월 4일
Can anyone explain why the following code is incorrect? It attempts to graph the solution to the differential equation y' = y'' which is ce^x.
kp = 3;
kpm = 30;
kmp = 25;
klm = 15;
kl = 1;
f = @(t,y) [(y(2))];
tspan = [0, 25];
xinit = [0.01];
ode45(f, tspan, xinit)
legend('p(t)', 'm(t)', 'l(t)')
  댓글 수: 2
darova
darova 2020년 2월 4일
Please explain how did you write your equation? Why
f = @(t,y) [(y(2))];
Aleem Andrew
Aleem Andrew 2020년 2월 4일
As in the code from the linked page that line equates the first derivative of y to the second derivative.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 2월 4일
Your xinit is a scalar, so the second parameter received by f will be a scalar; it is not possible to index the second element of a scalar.
If you are working with second derivatives then your xinit should be providing boundary conditions for the first derivative and second derivative, and your f should return a column vector with the same number of elements that xinit has.

카테고리

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