Integrating second order differential equation BVP error

4 ビュー (過去 30 日間)
matlabkid602
matlabkid602 2018 年 10 月 31 日
編集済み: Stephan 2018 年 11 月 1 日
I get the error "Warning: Explicit solution could not be found." when trying to integrate this BVP.
I've attached a picture of the DE here.
https://imgur.com/a/j6eJERx
Why is it failing?
syms y(x)
epsilon = .0001
ode = epsilon*diff(y,x,2)-(3*x+2)*diff(y,x)+y^2 == 0;
cond1 = y(0) == -3/log(2);
cond2 = y(1) == 1;
conds = [cond1 cond2];
ySol(x) = dsolve(ode,conds)
end

採用された回答

Stephan
Stephan 2018 年 11 月 1 日
編集済み: Stephan 2018 年 11 月 1 日
Hi,
i dont think that there is a analytical solution to this problem. You can solve this numeric by using symbolic Toolbox for creating a function handle to this in the first step (or you do this by hand):
syms y(x)
epsilon = .0001
ode = odeToVectorField((epsilon*diff(y,x,2)-(3*x+2)*diff(y,x)+y^2 == 0),y(x));
ode_fun = matlabFunction(ode,'Vars',{'x','Y'})
The code above gives you a system of first order odes and a function handle:
ode =
Y[2]
10000*(3*x + 2)*Y[2] - 10000*Y[1]^2
vars =
y
Dy
ode_fun =
function_handle with value:
@(x,Y)[Y(2);Y(1).^2.*-1.0e4+(x.*3.0+2.0).*Y(2).*1.0e4]
Using the vars Information you know that y=Y(1) and Dy=Y(2). Then you can formulate the problem for numeric solving by bvp5c:
odefun = @(x,Y)[Y(2);Y(1).^2.*-1.0e4+(x.*3.0+2.0).*Y(2).*1.0e4];
bcfun = @(ya,yb)[ya(1); yb(1)-1];
x = linspace(0,1,10);
yinit = [0 0];
solinit = bvpinit(x,yinit);
sol = bvp5c(odefun,bcfun,solinit);
% plot function graph of y
subplot(2,1,1)
plot(sol.x,sol.y(1,:),'r','lineWidth',2)
xlim([0.9998 1])
% plot first derivative of y
subplot(2,1,2)
plot(sol.x,sol.y(2,:),'g','lineWidth',2)
xlim([0.9998 1])
Note that the x-values of the plot are not from 0...1, due to the function would look like a step function in x=1 otherwise.
Best regards
Stephan

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by