BVP4c error. Would anyone help to find any error and correct this ?
์กฐํ ์: 2 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
%๐ฆ"= ๐ฆ ฬ^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
๋๊ธ ์: 0
๋ต๋ณ (1๊ฐ)
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.
๋๊ธ ์: 0
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
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!