MATLAB Answers

Info

This question is closed. Reopen it to edit or answer.

BVP4C is returning x and y output vecotrs that are different in length from the original x vector. Is there a way to fix the length of x ans y?

1 view (last 30 days)
Saeid
Saeid on 21 Aug 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
I would like to solve a set of BVPs with the starting x values (second line of the code below) in a vector of length 50, but when I check the solution the final vector has the length 99. Is there a way to fix the length of x (and consequently, y) from the start?
H0=2e-3; GG0=4e4; TT0=32; K0=1.7e-5; Pz=1e5;
x=linspace(1e-6,H0/2,50);
solinit = bvpinit(x, @guess);
sol=bvp4c(@bvpfcn,@bcfcn,solinit);
xx=sol.x; yy=sol.y;
function dydx=bvpfcn(x,y)
% y1=Txy(r), y2=u(r)
b2_4ac=GG0^2-4*K0*GG0*(y(1))^2;
tyy=(-0.5*(GG0-sqrt(b2_4ac)));
dydr=[Pz -(tyy/TT0)/(K0*y(1)*(tyy+GG0))];
%dydr=[Pz(ii) (y(1)/TT0)/(-K0*y(1)^2+tyy+GG0)];
end
function res=bcfcn(ya,yb)
res=[ya(1) yb(2)];
end
function g=guess(x)
g=[1e4 1e-2];
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!