필터 지우기
필터 지우기

How to use ODE4 to solve second order ODE

조회 수: 9 (최근 30일)
Khang Nguyen
Khang Nguyen 2022년 10월 11일
편집: Torsten 2022년 10월 11일
How to use ode4 to solve second order ODE? ode4(https://www.mathworks.com/matlabcentral/answers/98293-is-there-a-fixed-step-ordinary-differential-equation-ode-solver-in-matlab-8-0-r2012b)
I tried to put in the following equation into matlab
.
Initial Condition:
This gave me an error
syms y(x)
Dy = diff(y);
ode = diff(y,2) == (1/4)*y + (1/2);
cond1 = y(0) == 0;
cond2 = Dy(0) == 1;
h = 0.5
y0 = [0 1];
tspan = 0:h:60
yx = ode4(ode, tspan, y0);
plot(tspan, yx)

답변 (1개)

Torsten
Torsten 2022년 10월 11일
편집: Torsten 2022년 10월 11일
ode4 works with 1st order systems of ODEs. Yours is a 2nd order equation.
Can you write your equation as a system of two first order equations that ode4 would accept ?

카테고리

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