help to find error in this?

2 次查看(过去 30 天)
function Needle
a=0.01;
Pr=3.0;R=2.0;Nr=10;Ec=0.3;
solinit= bvpinit(linspace(a,40,100),[0 0 0 0 0]);
sol = bvp4c(@Needleode,@Needlebc,solinit);
eta = sol.x;
f = sol.y;
disp(f(2,1))
Cf=8*a^(1/2)*f(3);
disp(Cf)
function dfdeta = Needleode(eta,f)
f1_thetha=f(4)*(R-1)+1;
f2_thetha=eta*(1+4*(f1_thetha)^3/3*Nr);
dfdeta = [ f(2)
f(3)
-(1/(2*eta))*(f(1)*f(3)+2*f(3))
f(5)
-(f(5)+Pr*f(1)*f(5)/2+4*Ec*Pr*eta*(f(3))^2+2*f(5)*(f1_thetha)^3/3*Nr+4*eta*f(5)^2*(R-1)*(f1_thetha)^2/Nr)/f2_thetha
];
function res = Needlebc(f0,finf)
a=0.01;e=0.7;
res = [f0(1)-(a*e/2)
f0(2)-e/2
finf(2)-(1-e)/2
f0(1)-1
finf(1)-0
];
Error which i found is:
Undefined function or variable 'R'.
Error in Needle>Needleode (line 14)
f1_thetha=f(4)*(R-1)+1;
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in Needle (line 5)
sol = bvp4c(@Needleode,@Needlebc,solinit);
>>

采纳的回答

Sulaymon Eshkabilov
Here is the corrected code. But you need to check your Jacobian matrix formulations; otherwise, this exercise is not solvable:
global R Nr Pr Ec
a=0.01;
Pr=3.0;R=2.0;Nr=10;Ec=0.3;
solinit= bvpinit(linspace(a,40,100),[0 0 0 0 0]);
sol = bvp4c(@Needleode,@Needlebc,solinit);
eta = sol.x;
f = sol.y;
disp(f(2,1))
Cf=8*a^(1/2)*f(3);
disp(Cf)
function dfdeta = Needleode(eta,f)
global R Nr Pr Ec
f1_thetha=f(4)*(R-1)+1;
f2_thetha=eta*(1+4*(f1_thetha)^3/3*Nr);
dfdeta = [ f(2);
f(3);
-(1/(2*eta))*(f(1)*f(3)+2*f(3));
f(5);
-(f(5)+Pr*f(1)*f(5)/2+4*Ec*Pr*eta*(f(3))^2+2*f(5)*(f1_thetha)^3/3*Nr+4*eta*f(5)^2*(R-1)*(f1_thetha)^2/Nr)/f2_thetha ];
end
function res = Needlebc(f0,finf)
a=0.01;e=0.7;
res = [f0(1)-(a*e/2);
f0(2)-e/2;
finf(2)-(1-e)/2;
f0(1)-1;
finf(1)-0];
end
  3 个评论
Nk
Nk 2023-2-4
Error using bvp4c (line 251)
Unable to solve the collocation equations -- a singular Jacobian encountered.
Error in NK (line 6)
sol = bvp4c(@Needleode,@Needlebc,solinit);
it shows this error after running your code i couldn't understand how to fix it
Sulaymon Eshkabilov
Check the BC values and Jacobian matrix formualtions of your exercise.

请先登录,再进行评论。

更多回答(1 个)

Torsten
Torsten 2023-2-4
移动:Torsten 2023-2-4
Your boundary conditions contradict each other:
f0(1)-(a*e/2)
f0(1)-1
So f(1) at x = 0.01 should be at the same time 0.01*0.7/2 = 0.0035 and 1. That's not possible.

类别

Help CenterFile Exchange 中查找有关 DSP Algorithm Acceleration 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by