简体   繁体   English

Matlab-解微分方程

[英]Matlab - Solving a diferential equation

i'm trying to solve this equation: 我正在尝试解决这个问题:

y''+3yy'' with y(0)=0 ; y''+ 3yy''且y(0)= 0; y(2)=1 y(2)= 1

I've tried using bvp4c and i know i have to turn it into a system of DE but i am really stuck, any help would be appreciated, thanks :) 我试过使用bvp4c,我知道我必须将其转换为DE系统,但是我真的很困,不胜感激,谢谢:)

I've tried this, but really is just guessing 我已经尝试过了,但实际上只是在猜测

function sss=sos()
solinit=bvpinit(linspace(0,2,10),[1,0,0]);
answ=bvp4c(@twoode,@bcfun,solinit)
x=linspace(0,2);
y=deval(answ,x);
plot(x,y(1,:));
end

function dydx=twoode(x,y)
dydx=[y(3),3*y(1)+y(2)];
end

function res=bcfun(ya,yb)
res=[ya(1),yb(1)+2];
end

Start with (if the original equation is y'' + 3 * y * y' = 0) 从开始(如果原始方程为y''+ 3 * y * y'= 0)

function sss = sos()
solinit = bvpinit(linspace(0, 2, 10), [1, 0]);
answ = bvp4c(@twoode, @bcfun, solinit);
x = linspace(0, 2);
y = deval(answ, x);
plot(x, y(1, :));
end

function dydx = twoode(x, y)
dydx = [y(2); -3 * y(1) * y(2)];
end

function res = bcfun(ya, yb)
res = [ya(1); yb(1) - 1];
end

图形

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM