error is using bvpset in bvp4c

9 visualizaciones (últimos 30 días)
Syed
Syed el 24 de Sept. de 2024
Comentada: Syed el 25 de Sept. de 2024
Hi, I am Syed,
I like to have an output with 6 or more than 6 decimal place (for example: 3.033334), without bvpset i am getting the output upto 4 decimal places, but i like to have upto to 6 or 8 decimal places, please guide me to get the desired output
The error i am getting is
Error using <=
Not enough input arguments.
My program is given below
close all
clc
phi=0.1;
phi1=2;
phi2=2;
Betaf=0.00021;
Betas=0.000058;
sigmaf=0.005;
sigmas=580000;
GR=2;
EM2=20;
Rof=997.1;
Ro=5;
c=0;
Ros=4420;
h=0.5;
Hc=0.25;
K=1;
R=1;
e1=(1./((1-phi).^2.5));
e2=(1-phi)+(phi.*(Ros./Rof));
e3=(1-phi)+phi.*((Ros.*Betas)./(Rof.*Betaf));
sigma=(sigmas./sigmaf);
e4=1-((3*(1-sigma).*phi)./((2+sigma)+(1-sigma).*phi));
gama1=e2./e1;
gama2=1/e1;
gama3=e3./e1;
s1=(e4./(phi1.*(1-i.*Hc)));
s2=(e4./(phi2.*(1-i.*Hc)));
dydx=@(x,y)[y(3);
y(4);
-EM2.*gama2.*y(4)+2.*i.*Ro.*gama1.*y(1)+gama3.*GR.*x+R.*gama1;
(-e4./(1-i.*Hc)).*y(3)];
BC = @(ya,yb)[ya(1);yb(1)-c;ya(4)-s1.*ya(2);yb(4)+s2.*yb(2)];
yinit = [0.01;0.01;0.01;0.01];
options = bvpset('stats','on','RelTol',le-3);
solint = bvpinit(linspace(0,1,50),yinit,options);
U1 = bvp4c(dydx,BC,solint);
dudy1=U1.y(3,1)

Respuesta aceptada

Shashi Kiran
Shashi Kiran el 24 de Sept. de 2024
Hi @Syed,
I understand that you are aiming to obtain an output with 6 or more decimal places but are encountering errors.
Here are my observations and corrections for your code:
  • The error was because le-3 is not a valid expression. It should be 1e-3, which is the proper MATLAB syntax for .
options = bvpset('stats','on','RelTol',1e-3);
  • The bvpinit function is used to initialize the solution guess and mesh, and it doesn't accept the options structure as an argument.
solint = bvpinit(linspace(0,1,50),yinit);
  • The correct place to pass the options structure is in the bvp4c function call. This allows the solver to use the relative tolerance (RelTol) and print statistics ('stats', 'on').
U1 = bvp4c(dydx,BC,solint,options);
Here is the output following these corrections:
Refer to the following documentations for more details about the functions:
  1. bvpset: https://www.mathworks.com/help/matlab/ref/bvpset.html
  2. bvpinit: https://www.mathworks.com/help/matlab/ref/bvpinit.html
  3. bvp4c: https://www.mathworks.com/help/matlab/ref/bvp4c.html
Hope this solves your query.
  4 comentarios
Shashi Kiran
Shashi Kiran el 25 de Sept. de 2024
Additionally,
To set the default formatting for long in MATLAB, follow these steps:
- On the MATLAB homepage, go to Home.
- Navigate to Preferences.
- Under Command Window, select Text Display, then choose Numeric Format and set it to long.
Syed
Syed el 25 de Sept. de 2024
I got it now, thanks a lot

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by