Why bvp4c not works?

2 ビュー (過去 30 日間)
Andriy Kavetsky
Andriy Kavetsky 2016 年 10 月 29 日
回答済み: Bill Greene 2016 年 10 月 30 日
I have an error in using bvp4c, my result is wrong
My task is to solve
3*y"+2*y'=x
y(0)=-2
y(1)=6
my matlab code:
dydt=@(x,y)[y(2); y(2)+x];
bc=@(ya,yb)[ya(1)+2; yb(1)-6];
yinit=@(x)[exp(-x); -exp(-x)];
solinit=bvpinit(linspace(0,1,20),yinit);
sol=bvp4c(dydt,bc,solinit);
plot(sol.x,sol.y(1,:))
Could you help me to find what wrong?

回答 (1 件)

Bill Greene
Bill Greene 2016 年 10 月 30 日
I think you want: dydt=@(x,y)[y(2); (x-2*y(2))/3];

カテゴリ

Help Center および File ExchangeSimulink PLC Coder についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by