How can I solve this BVP problem which is second-order ODE with variable coefficient?

Hi there,
I have some problems regarding solving this problem on MATLAB:
y'' + [(1-10x^2)/x]*y' = 0
BC: y(0) = 1, y(1) = 0
Thanks in advance.

2 件のコメント

Stephan
Stephan 2020 年 11 月 30 日
What have you tried so far?
Sohrab Askarli
Sohrab Askarli 2020 年 11 月 30 日
編集済み: Sohrab Askarli 2020 年 11 月 30 日
close all;
fun = @(x,y)[y(2); -x.*0.1e1*y(2) + x.*1.0e1*y(2)];
bc = @(ya, yb) [ya(1) - 1; yb(1)];
xmesh = linspace(0, 1, 100);
solinit = bvpinit(xmesh, [1 0]);
sol = bvp4c(fun, bc, solinit);
figure;
plot(sol.x, sol.y);
This is what I have made so far, however I'm not satisfied with the result, but I dunno what to change. Theoretically, it seems ok to me, hence, I cannot find where I make mistake.

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

 採用された回答

Stephan
Stephan 2020 年 11 月 30 日
編集済み: Stephan 2020 年 11 月 30 日
Your function handle appears to be incorrect:
syms y(x)
eq = diff(y,x,2) + ((1-10*x^2)/x)*diff(y,x,1) == 0;
[V,S] = odeToVectorField(eq);
fun = matlabFunction(V,'Vars',{'x','Y'})
gives:
fun =
function_handle with value:
@(x,Y)[Y(2);((x.^2.*1.0e+1-1.0).*Y(2))./x]
additionally your function gets singular at x=0, to avoid this:
fun = @(x,Y)[Y(2);((x.^2.*1.0e+1-1.0).*Y(2))./x];
bc = @(ya, yb) [ya(1) - 1; yb(1)];
xmesh = linspace(1e-4, 1, 100);
solinit = bvpinit(xmesh, [1 0]);
sol = bvp4c(fun, bc, solinit);
figure;
yyaxis left
plot(sol.x, sol.y(1,:),'LineWidth',2)
yyaxis right
semilogy(sol.x, sol.y(2,:),'LineWidth',2)
Note that the right axis is log scaled:

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by