After running the code for (f ') w.r.t x , we need to draw( f ' ) w.r.t G (in X-axis) while varying n=0, 0.5, 1
1 次查看(过去 30 天)
显示 更早的评论
function main
Pr=1;K=1;L=-1;S=0.1;
n=input('n=');
a=linspace(0,6,100);
G=linspace(0,7,100);
solinit=bvpinit(a,G,[0 1 0 1 0 0 1]);
sol=bvp4c(@ode,@bc,solinit);
xint=a;
sxint=deval(sol,xint);
function res=bc(ya,yb,G)
res=[ya(1)-S; ya(2)-L; ya(4)+n*ya(3); ya(6)-1; yb(2)-1; yb(4); yb(6);];
end
function dydx=ode(x,y,G)
dydx=[y(2); y(3);(y(2)^2-1-y(1)*y(3)-K*y(5)-G*(1-y(2)))/(1+K);y(5);2*(y(2)*y(4)-y(1)*y(5)+K*(2*y(4)+y(3)))/(2+K);y(7);-Pr*y(1)*y(7)];
end
plot(xint,sxint([2],:),'Linewidth',2); %for f'
xlabel('\eta');
ylabel('f^\prime');
hold on
end
ERROR occurs as:
n=0
Error using bvparguments (line 108)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT):
The derivative function ODEFUN should return a column vector of length 100.
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in (line 7)
sol=bvp4c(@ode,@bc,solinit);
0 个评论
采纳的回答
Walter Roberson
2019-2-21
your G is length 100. You pass it to bvpinit so matlab knows that your ode function works with 100 derivatives. but your ode only returns 7 rather than 100.
I notice that your upper bound for G is 7, the same number as the derivatives calculated . I wonder if perhaps you used linspace incorrectly .
13 个评论
Walter Roberson
2019-2-27
You need the PDE Toolbox instead of what you are doing. You will have to learn how to use it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Conditions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!