Help me to set this code?

1 次查看(过去 30 天)
Niba Kainat
Niba Kainat 2023-5-16
评论: Torsten 2023-5-16
hi I want to get one specific error value for some specific parameter change. I'm unable to extract specific value of error.
nk
Warning: Unable to meet the tolerance without using more than 2000 mesh points.
The last mesh of 1000 points and the solution are available in the output argument.
The maximum error is 1.62998, while requested accuracy is 0.0001.
function nk
a=0.1;
mu=0.0;
r=2.0;
Ec=0.3;
Nr=10;
solinit= bvpinit(linspace(a,100,1000),[0 0 0 0 0]);
% Set the options with the desired RelTol value
relTol = 1e-4;
AbsTol=1e-6;
options1 = bvpset('RelTol', relTol,'AbsTol',AbsTol);
sol = bvp5c(@Needleode,@Needlebc,solinit,options1);
eta = sol.x; % mesh points
f = sol.y; % solution values at the mesh points
plot(eta,f(1,:))
% Calculate the maximum error
exact_solution=1e-4;
E=max(abs(f - exact_solution));
%disp(E)
% Calculate the number of mesh points
num_meshpoints = length(eta);
%disp(num_meshpoints)
end
function dfdeta = Needleode(eta,f)
Pr=6.8;
Ec=0.3;
mu=0.0;
k=0.0;
Nr=10;
r=3.0;
t1=1+mu*f(4);
t2=1+k*f(4);
u=f(4)*(r-1)+1;
v=eta*(t2+(4/(3*Nr))*(u)^3);
ff1=-(1/(2*eta))*((1/t1)*-2*eta*mu*f(3)*f(5)+t1*f(1)*f(3)+2*f(3));
k_1=f(5)*t2+k*eta*(f(5)^2);
k_2=(1/2)*Pr*f(1)*f(5)+(1/t1)*4*Pr*Ec*f(3)^2;
k_3=(2/(3*Nr))*f(5)*(u^3);
k_4=(4/Nr)*(u^2)*eta*(f(5)^2)*(r-1);
ff2=-(1/(v)*(k_1+k_2+k_3+k_4));
dfdeta=[f(2);f(3);ff1;f(5);ff2];
end
function res = Needlebc(f0,finf)
a=0.1;e=1e-2;
res = [f0(1)-(a*e/2)
f0(2)-e/2
finf(2)-(1-e)/2
f0(4)-1
finf(4)-0
];
end
This is the code .
second i give the the exact solution value myself. How to calculate it manually?
  1 个评论
Torsten
Torsten 2023-5-16
I don't understand what you try to do and what you are asking for.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by