フィルターのクリア

Solve a second order differential equation in matlab?

16 ビュー (過去 30 日間)
Andrew
Andrew 2014 年 10 月 24 日
回答済み: Ritu Rani 2021 年 10 月 6 日
I have to solve the equation d2y/dx2+.5dy/dx+7y=0 with initial conditions y(0)=4 y'(0)=0 with x ranging from 0 to 5 with a step size of .5. How do I go about doing this?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 24 日
You can transform your equation d2y/dx2=.-5dy/dx-7y to get:
y1=y
y2=dy/dx
dy1=dy/dx=y2
dy2=d2y/d2x=-5dy/dx-7y=-5y2-7y1
Create a file named myode.m
function dy=myode(x,y)
dy=[0;0]
dy(1)=y(2)
dy(2)=-5*y(2)-7*y(1)
Then run these lines
yin=[0 4 ] % initial values
time=[0 5]
[x,y]=ode45(@myode,time,yin)
plot(x,y)

その他の回答 (2 件)

Jaisai Pranav Yannam
Jaisai Pranav Yannam 2021 年 2 月 11 日
y''+16y=2 cos^2x,y(0)=0,y'(0)=1

Ritu Rani
Ritu Rani 2021 年 10 月 6 日

カテゴリ

Help Center および File ExchangePartial Differential Equation Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by