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
Sulaymon Eshkabilov 2023년 2월 4일

1 개 추천

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

Walter Roberson
Walter Roberson 2023년 2월 4일
이동: the cyclist 2023년 2월 4일
https://www.mathworks.com/help/matlab/math/parameterizing-functions.html
global is not recommended
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
Sulaymon Eshkabilov 2023년 2월 4일
Check the BC values and Jacobian matrix formualtions of your exercise.

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

추가 답변 (1개)

Torsten
Torsten 2023년 2월 4일
이동: Torsten 2023년 2월 4일

0 개 추천

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.

카테고리

제품

릴리스

R2018b

질문:

Nk
2023년 2월 4일

이동:

2023년 2월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by