BVP4c error. Would anyone help to find any error and correct this ?

์กฐํšŒ ์ˆ˜: 2 (์ตœ๊ทผ 30์ผ)
Md Sojib
Md Sojib 2024๋…„ 4์›” 15์ผ
๋‹ต๋ณ€: Ayush Anand 2024๋…„ 4์›” 15์ผ
%๐‘ฆ"= ๐‘ฆ ฬ‡^2/2๐‘Ÿ+๐‘ ๐‘–๐‘›๐‘ฆ/๐‘Ÿ+(y'cosy)/๐‘Ÿ+ 2/๐œ†^2 (siny) โˆ’(y/๐‘Ÿ)r' -cosy/r;
%where ๐œ† is constant
% r'=cosy
%h'=siny
% Boundary conditions: r(0)=Rsin(alpha), h(0)=Rcos(alpha), y(0)=alpha,
% y(inf)=0, y'(inf)=0
R = 10.2e-9;
sc = 390e-18;
solinit = bvpinit(linspace(-10,10,50),@init_guess);
sol = bvp5c(@f1, @bc1, solinit);
%options = bvpset('RelTol', 1e-8, 'states', 'on');
function dydx=f1(x,y)
y1=y(1); %y
y2=y(2); %r
y3=y(3); %h
y4=y(4); %y'
y2p=cos(y1);
y3p=sin(y1);
ypp=(y4^2)/(2*y2)+sin(y1)/y2+y4*cos(y1)/y2+(2/1.8e-9^2)*y3-y1*y2p/y2-cos(y1)/y2;
dydx=[y4;y2p;y3p,ypp];
end
function res=bc1(y0,yinf)
R=10.2e-9;
sc=390e-18;
alpha = (1/(2*pi*R^2)-sc)*(sc*sqrt(4*pi*R^2)-sc);
res=[y0(2)-R*sin(alpha); y0(3)+R*cos(alpha); y0(1)-alpha; yinf(1); yinf(4)];
end
function guess = init_guess(x)
guess = [pi-x/20,sin(x/20),x,0];
end

๋‹ต๋ณ€ (1๊ฐœ)

Ayush Anand
Ayush Anand 2024๋…„ 4์›” 15์ผ
Hi,
You need to replace the comma before ypp with a semi-colon to create a 4-column vector
%Replace dydx=[y4;y2p;y3p,ypp]; with
dydx=[y4;y2p;y3p;ypp];
Also, you have a 4-column vector defined as the output of "f1" , and the system is a 4th order differential, while there are 5 boundary conditions defined as the output of "bc1" . You will need to remove one of the boundary conditions for the dimensions to match with "f1", as "bvp5c" expects the number of boundary conditions to match the order of the differential.
You can read more about "bvp5c" here: https://www.mathworks.com/help/matlab/ref/bvp5c.html

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Boundary Value Problems์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by