フィルターのクリア

Unable to solve the collocation equations -- a singular Jacobian encountered.

2 ビュー (過去 30 日間)
Della
Della 2023 年 5 月 8 日
編集済み: Torsten 2023 年 5 月 8 日
Hello everyone,
I'm new to Matlab and have a simple question. I'd like to plot h=x*y, where y takes the form of an ODE. How do I plot h in this x interval, [0,4]?
My code is:
syms y Dy D2y x Y
ode = y-(1/(Dy/y+(D2y*x)/y))^2;
ode1 = solve(ode==0,D2y);
ode2 = matlabFunction(ode1);
odefcn = @(x,y)[y(2);f(y(2),x,y(1))];
bcfcn = @(ya,yb)[ya(1)-2;yb(1)];
xmesh = linspace(0,4,10);
solinit = bvpinit(xmesh, [0 0]);
sol = bvp4c(odefcn,bcfcn,solinit);
plot(sol.x,sol.y(1,:))

採用された回答

Torsten
Torsten 2023 年 5 月 8 日
編集済み: Torsten 2023 年 5 月 8 日
You have an ODE that has a singularity at x=0. Further, solving for D2y leads to two different differential equations. You must decide which is the one you want to solve.
Thus the results below should be treated with care.
syms y Dy D2y x Y
ode = y-(1/(Dy/y+(D2y*x)/y))^2;
ode1 = solve(ode==0,D2y)
ode1 = 
ode2 = matlabFunction(ode1(1),'Vars',{x,[y Dy]})
ode2 = function_handle with value:
@(x,in2)(in2(:,1).*(sqrt(1.0./in2(:,1))-in2(:,2)./in2(:,1)))./x
odefcn = @(x,y)[y(2);ode2(x,[y(1),y(2)])];
bcfcn = @(ya,yb)[ya(1)-2;yb(1)];
xmesh = linspace(1e-3,4,10);
solinit = bvpinit(xmesh, [1 1]);
sol = bvp4c(odefcn,bcfcn,solinit);
plot(sol.x,sol.x.*sol.y(1,:))
Warning: Imaginary parts of complex X and/or Y arguments ignored.

その他の回答 (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