help to find error in this?

3 views (last 30 days)
Nk
Nk on 4 Feb 2023
Moved: the cyclist on 4 Feb 2023
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);
>>

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 4 Feb 2023
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 Comments
Nk
Nk on 4 Feb 2023
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
Sulaymon Eshkabilov on 4 Feb 2023
Check the BC values and Jacobian matrix formualtions of your exercise.

Sign in to comment.

More Answers (1)

Torsten
Torsten on 4 Feb 2023
Moved: Torsten on 4 Feb 2023
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.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!