error is using bvpset in bvp4c

조회 수: 7 (최근 30일)
Syed
Syed 2024년 9월 24일
댓글: Syed 2024년 9월 25일
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)

채택된 답변

Shashi Kiran
Shashi Kiran 2024년 9월 24일
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
Shashi Kiran
Shashi Kiran 2024년 9월 25일
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 2024년 9월 25일
I got it now, thanks a lot

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by