How to solve y''+y'-y=x+1 using y(0)=1 and y'(0)=0. Plot the solution.

7 ビュー (過去 30 日間)
Sheila Mae Soriano
Sheila Mae Soriano 2021 年 9 月 9 日
コメント済み: Sheila Mae Soriano 2021 年 9 月 13 日
How to solve y''+y'-y=x+1 using y(0)=1 and y'(0)=0. Plot the solution.
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 9 月 9 日
syms y(x)
Dy=diff(y);
ode=diff(y,x,2)+diff(y,x,1)-y==x+1;
cond1 = y(0)==1;
cond2=Dy(0)==0;
conds=[cond1 cond2];
sol=dsolve(ode,conds);
sol1=simplify(sol);
sol1
sol1 = 
Looks okay.
As a matter of style, since you compute Dy already, it does not make sense to use diff(y,x,1) in the ode:
ode=diff(y,x,2)+Dy-y==x+1;
Sheila Mae Soriano
Sheila Mae Soriano 2021 年 9 月 13 日
Thank you! Very helpful.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 9 日
The below is deliberately different than your question (because your question looks like homework to me.)
syms y(x)
dy = diff(y)
dy(x) = 
d2y = diff(dy)
d2y(x) = 
eqn = 5*d2y + 7*dy - 9*y == x^2 - 11*x + 13
eqn(x) = 
ic = [y(0) == 2, dy(0) == 1]
ic = 
sol = dsolve([eqn, ic])
sol = 
fplot(sol, [0 10])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by