1 view (last 30 days)

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);

Walter Roberson
on 21 Feb 2019

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 .

Walter Roberson
on 26 Feb 2019

Walter Roberson
on 27 Feb 2019

You need the PDE Toolbox instead of what you are doing. You will have to learn how to use it.

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

Start Hunting!
## 0 Comments

Sign in to comment.