6 views (last 30 days)

Pr = 1;

ODE = @(x,y) [y(2); y(3); -(1/2)*y(3)*y(1); y(5); - (Pr/2)*y(1)*y(5);];

BC = @(ya,yb)[ya(1);ya(2);ya(4)-1;yb(2)-1; yb(4);];

xa = 0; xb = 5; xn = linspace(xa,xb,100); x = xn;

solinit = bvpinit(x,[0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);

fV = deval(sol,0); p1 = fV(3); q1 = fV(5);

Pr = sym('Pr');x = sym('x');f0(x) = sym('f0(x)'); g0(x) = sym('g0(x)');

eqn0 = [ diff(f0,3) == 0, diff(g0,2) == 0];

cond0 = [f0(0) == 0, subs(diff(f0),0) == 0, subs(diff(f0),5) == 1, g0(0) == 1, g0(5) == 0];

F0 = dsolve(eqn0,cond0); f0 = F0.f0; g0 = F0.g0; % disp([f0,g0])

f1(x) = sym('f1(x)'); g1(x) = sym('g1(x)');

eqn1 = [ diff(f1,3) + (1/2)*f0*diff(f0,2) == 0, diff(g1,2) + (Pr/2)*f0*diff(g0) == 0];

cond1 = [f1(0) == 0, subs(diff(f1),0) == 0, subs(diff(f1),5) == 0, g1(0) == 0, g1(5) == 0];

F1 = dsolve(eqn1,cond1); f1 = F1.f1; g1 = F1.g1; %disp([f1,g1])

f2(x) = sym('f2(x)'); g2(x) = sym('g2(x)');

eqn2 = [ diff(f2,3) + (1/2)*(f0*diff(f1,2) + f1*diff(f0,2)) == 0, diff(g2,2) + (Pr/2)*(f0*diff(g1) + f1*diff(g0)) == 0];

cond2 = [f2(0) == 0, subs(diff(f2),0) == 0, subs(diff(f2),5) == 0, g2(0) == 0, g2(5) == 0];

F2 = dsolve(eqn2,cond2); f2 = F2.f2; g2 = F2.g2; %disp([f2,g2])

f3(x) = sym('f3(x)'); g3(x) = sym('g3(x)');

eqn2 = [ diff(f3,3) + (1/2)*(f0*diff(f2,2) + f1*diff(f1,2) + f2*diff(f0,2)) == 0, diff(g3,2) + (Pr/2)*(f0*diff(g2) + f1*diff(g1) + f2*diff(g0)) == 0];

cond2 = [f3(0) == 0, subs(diff(f3),0) == 0, subs(diff(f3),5) == 0, g3(0) == 0, g3(5) == 0];

F3 = dsolve(eqn2,cond2); f3 = F3.f3; g3 = F3.g3; %disp([f3,g3])

f = f0 + f1 + f2 + f3; f = collect(f,x);

g = g0 + g1 + g2 + g3; g = collect(g,x); g = subs(g,Pr,1);

figure(2),plot(xn,S(2,:),'LineWidth',1.5); axis([0 5 0 1]),xlabel('\bf\eta'); ylabel('\bff^{\prime}(\eta)');hold on,fplot(diff(f),[0 5],'--','LineWidth',1.5)

figure(4),plot(xn,S(4,:),'LineWidth',1.5); axis([0 5 0 1]),xlabel('\bf\eta'); ylabel('\bf\theta(\eta)');hold on,fplot(g,[0 5],'--','LineWidth',1.5)

%% I need to merge all the dsolve code into a single code to solve the problem given in attached pdf,

%% NUMERICAL code is of Eqns (12) & (14) but dsolve code is of Eqns (17) - (24).

%% Any attempt will be a great work

Opportunities for recent engineering grads.

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

Start Hunting!
## 9 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045406

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045406

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045506

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045506

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045551

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1045551

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1046395

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1046395

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1046561

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1046561

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1047196

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1047196

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1081748

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1081748

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1082653

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1082653

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1082988

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/607426-generalization-needed-in-dsolve-code#comment_1082988

Sign in to comment.