BVP4c error. Would anyone help to find any error and correct this ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
%𝑦"= 𝑦 ̇^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 comentarios
Respuestas (1)
Ayush Anand
el 15 de Abr. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Boundary Value Problems en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!