Hello, I am trying to solve the following code with bvp4c
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, I am trying to solve the following code with bvp4c
function inclinedcylinder(solver)
if nargin<1
solver = 'bvp4c' ;
end
bvpsolver = fcnchk(solver);
Pr = 7.0;A = -2.2;Ec = 1.0;Gr = 1;Rd = 1.0;Nt = 0.5;Nb = 0.7;Le = 3.0;M = 2;theta_w = 1.5;X = pi/4;
infinity = 10;
maxinfinity = 30;
solinit = bvpinit(linspace(1,infinity,30),[0 1 0 1 0 0 0]);
sol = bvpsolver(@inclode,@inclbc,solinit);
for Bnew = infinity+1:maxinfinity
solinit = bvpxtend(sol,Bnew);
sol = bvpsolver(@inclode,@inclbc,solinit);
eta = sol.x;
f = sol.y;
fprintf('\n');
fprintf('Value computed for f''(0)= %g is %7.5f.\n',0,f(3,1))
plot(eta,f(2,:),'m-.',eta(end),f(2,end),'Linesmoothing','on')
drawnow
axis([1 8 -1 0.1]);
xlabel('\eta')
ylabel(' f '' (\eta)')
end
hold on
function dfdeta = inclode(eta,f)
dfdeta = [ f(2)
f(3)
(f(2)^2-f(1)*f(3)+ A*(f(2)+eta*f(3))-Gr*f(4)*cos(X)-Gc*f(6)*cos(X)+M*f(2))/eta-f(3)/eta
f(5)
((Pr*(-f(1)*f(5))+Pr*(A*eta*f(5))-Pr*Ec*(f(3)^2)-Pr*Nb*eta*f(5)*y(7)-Pr*Nt*eta*(f(5)^2)))/eta-f(5)/eta*(1+Rd*(1+(theta_w-1)*f(4))^3)
f(7)
(-Le*(f(1)*f(7)-A*eta*f(7))-(Nt/Nb)*(f(5)+eta*((Pr*(-f(1)*f(5))+Pr*(A*eta*f(5))-Pr*Nb*eta*f(5)*y(7)-Pr*Nt*eta*(f(5)^2))/eta-f(5)/eta)))/eta-f(7)/eta
];
end
function res1 = inclbc(f1,finf)
res1 = [f1(1)-0
f1(2)+1
finf(2)-0
f1(4)-1
finf(4)-0
f1(7)-(Nt/Nb)*f1(5)-0
finf(6)-0
];
end end But I am getting the following error
Error in ==> bvp4c at 120 [n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in ==> inclinedcylinder at 17 sol = bvpsolver(@inclode,@inclbc,solinit);
??? Error: File: inclinedcylinder.m Line: 11 Column: 6 Expression or statement is incomplete or incorrect.
Kindly help me to solve this problem
댓글 수: 1
VIJAYKUMAR PATEL
2021년 8월 13일
Can you give me PDF file of the Differential equation so I can help you
채택된 답변
Jan
2017년 7월 27일
편집: Jan
2017년 7월 27일
The error message is very clear: There is an unexpected character in the line 11 of the file "inclinedcylinder.m". It is the 6th character of this line. So please be so kind and check this and if you do not get any clue, post which line this is.
Note that we cannot run this code due to the missing definition of "Gc". But at least I do not get any problems with parsing the file. Are you sure, that the posted code is the one which is failing?
댓글 수: 2
Jan
2017년 7월 28일
편집: Jan
2017년 7월 31일
[MOVED from answer section - please post comments in the comment section] Saranya S wrote:
Hello Simon, Thanks in advance!! I then subsitituted the value for Gc as 1. The error I get right now is ??? Undefined function or method 'y' for input arguments of type 'double'.
Error in ==> inclinedcylinder>inclode at 37 dfdeta = [ f(2)
Error in ==> bvparguments at 116 testODE = ode(x1,y1,odeExtras{:});
Error in ==> bvp4c at 120 [n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in ==> inclinedcylinder at 21 sol = bvpsolver(@inclode,@inclbc,solinit);
Jan
2017년 7월 28일
As the error message tells you, the term "y(7)" is not recognized as a variable and therefore Matlab searchs for a function with this name.
I suggest to read the error messages carefully.
참고 항목
카테고리
Help Center 및 File Exchange에서 Boundary Value Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!