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

采纳的回答

Jan
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
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
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.

请先登录,再进行评论。

更多回答(1 个)

Saranya S
Saranya S 2017-7-29
Thanks a lot Simon. Your note was so clear. I identified what to be done. Now I am OK with the code. Thanks again!!!
  1 个评论
Jan
Jan 2017-7-31
@Saranya S: Please do not post comments in the section for answers, but use the "Comment on this Answer" link. Thanks.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Boundary Value Problems 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by