Diff equation for finite element method
8 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
please could someone help me with this problem. I have to solve this diff equation y''= -6x+2 , x belongs to interval (0,2) and y(0)=y(2)=0
I tried to use dsolve
if true
x={0,2}
eqn2='D2y=-6(x)+2'
inits2='y(0)=0,y(2)=0'
y=dsolve(eqn2,inits2,'x')
end
but this does't work. And also tried to use ode45 function but i think this equation can't be solved by ode45 function. Could someone give me a hint how to do it, or better, example of code how to achieve solution. Many thanks
Sam
0 件のコメント
回答 (2 件)
Mischa Kim
2014 年 4 月 20 日
編集済み: Mischa Kim
2014 年 4 月 20 日
Sam, use a bvp solver
function pdetest()
solinit = bvpinit(linspace(0,2,5),[0 0]);
sol = bvp4c(@mypde,@mybc,solinit);
x = linspace(0,2);
y = deval(sol,x);
plot(x,y(1,:));
end
function dydx = mypde(x,y)
dydx = [y(2); -6*x + 2];
end
function res = mybc(ya,yb)
res = [ya(1); yb(1)];
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!