What changes are needed to run the code

Psi = pi/2; L1 = 0.1; L2 = 0.1; L = 0.1; Pr = 1; M = 5;
Ec = 0.5; Nb = 0.5; Nt = 0.1; fw = 0.5; Q = 0.1; Le = 2; Kc = 1;
A = linspace(-1,1,101);
for L = [1 2 3]/10
BC = @(ya,yb)[ ya(1)-fw; ya(2)+1; ya([4;7])-1; yb([2;4;6]) ];
ODE = @(x,y)[ y(2); y(3); ( A.*(y(2)+(1/2)*x*y(3)) - y(1)*y(3) + y(2)*( y(2)+M^2*(sin(Psi))^2) - L1*y(4) - L2*y(6))/(1+(1/L));
y(5); -Pr*( y(1)*y(5) - (1/2)*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4) );
y(7); -Le*Pr*( y(1)*y(7)-(1/2)*A.*x*y(7)-Kc*y(6) ) - (Nt/Nb)*(-Pr*( y(1)*y(5) - (1/2)*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4) )) ];
xa = 0; xb = 6; xn = linspace(xa,xb,101); x = xn; solinit = bvpinit(x,[0 1 0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit);
S = deval(sol,x); f0 = deval(sol,xa);
figure(1);plot(A,S(2,:),'-','LineWidth',2);xlabel('\bf\eta','color','b'); ylabel('\bff^\prime(\eta)','color','b');hold on,
end
Error using vertcat
Dimensions of arrays being concatenated are not consistent.

Error in solution (line 6)
ODE = @(x,y)[ y(2); y(3); ( A.*(y(2)+(1/2)*x*y(3)) - y(1)*y(3) + y(2)*( y(2)+M^2*(sin(Psi))^2) - L1*y(4) - L2*y(6))/(1+(1/L));

Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});

Error in bvp5c (line 129)
bvparguments(solver_name,ode,bc,solinit,options);
%% ERROR is:
Dimensions of matrices being concatenated are not consistent.
%% Help needed to run

Answers (1)

Jan
Jan on 16 Nov 2021
Edited: Jan on 16 Nov 2021
ODE = @(x,y) [ ...
y(2); ...
y(3); ...
(A.*(y(2)+0.5*x*y(3)) - y(1)*y(3) + y(2)*( y(2)+M^2*(sin(Psi))^2) - L1*y(4) - L2*y(6))/(1+(1/L)); ...
y(5); ...
-Pr*(y(1)*y(5) - 0.5*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4)); ...
y(7); ...
-Le*Pr*(y(1)*y(7) - 0.5*A.*x*y(7)-Kc*y(6)) - (Nt/Nb)*(-Pr*(y(1)*y(5) - 0.5*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4)))];
Yes, the 3rd, 5th and 7th element have the size 1x101, while the others are scalars. This comes from the vector A. I cannot guess, what you want to do instead.

7 Comments

Hi Jan
Actually I am trying to draw S(2,:) w.r.t A ( varies in x-axis ) for different values of L = [1 2 3]/10
i.e. plot(A,S(2,:))
Then you have to run the integration for all values of A. You cannot find all different trajectories with one integration.
Psi = pi/2;
L1 = 0.1;
L2 = 0.1;
L = 0.1;
Pr = 1;
M = 5;
Ec = 0.5;
Nb = 0.5;
Nt = 0.1;
fw = 0.5;
Q = 0.1;
Le = 2;
Kc = 1;
A = linspace(-1, 1, 10);
xa = 0;
xb = 6;
xn = linspace(xa,xb,101);
x = xn;
figure;
axesH = axes('NextPlot', 'add');
for L = [1 2 3]/10
for iA = A
BC = @(ya,yb)[ ya(1)-fw; ya(2)+1; ya([4;7])-1; yb([2;4;6]) ];
ODE = @(x,y) [ ...
y(2); ...
y(3); ...
(iA.*(y(2)+0.5*x*y(3)) - y(1)*y(3) + y(2)*( y(2)+M^2*(sin(Psi))^2) - L1*y(4) - L2*y(6))/(1+(1/L)); ...
y(5); ...
-Pr*(y(1)*y(5) - 0.5*iA.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4)); ...
y(7); ...
-Le*Pr*(y(1)*y(7) - 0.5*iA.*x*y(7)-Kc*y(6)) - (Nt/Nb)*(-Pr*(y(1)*y(5) - 0.5*iA.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4)))];
solinit = bvpinit(x, [0 1 0 1 0 1 0]);
sol = bvp5c(ODE, BC, solinit);
S = deval(sol, x);
f0 = deval(sol, xa);
plot(axesH, iA, S(2,:), '.', 'LineWidth', 2);
end
end
xlabel('\bf\eta','color','b');
ylabel('\bff^\prime(\eta)','color','b');
I assume you want to modify the oputput. Maybe collect the different output of S(:,2) in an array at first and draw it as plot(A, collectedS)?
@ Dear Jan
Thanks for your try. But unfortunately Your attempt is not upto mark (I may be wrong).
Please have a look into my trial. It gives so many curves instead of THREE. Can it be modified?
A = -0.50; Psi = pi/2; L1 = 0.1; L2 = 0.1; L = 0.1; Pr = 2; M = 5;
Ec = 0.5; Nb = 0.5; Nt = 0.1; fw = 0.5; Q = 0.1; Le = 2; Kc = 1;
Av = linspace(-1,1,101);
for M = [1 2 3]
for i = 1:length(Av)
A = Av(i);
BC = @(ya,yb)[ ya(1)-fw; ya(2)+1; ya([4;7])-1; yb([2;4;6]) ];
ODE = @(x,y)[ y(2); y(3); ( A.*(y(2)+(1/2)*x*y(3)) - y(1)*y(3) + y(2)*( y(2)+M^2*(sin(Psi))^2) - L1*y(4) - L2*y(6))/(1+(1/L));
y(5); -Pr*( y(1)*y(5) - (1/2)*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4) );
y(7); -Le*Pr*( y(1)*y(7)-(1/2)*A.*x*y(7)-Kc*y(6) ) - (Nt/Nb)*(-Pr*( y(1)*y(5) - (1/2)*A.*x*y(5) + Nb*y(5)*y(7) + Nt*y(5)^2 + M^2*Ec*y(2)^2+Q*y(4) )) ];
xa = 0; xb = 6; xn = linspace(xa,xb,101); x = xn; solinit = bvpinit(x,[0 1 0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit);
S = deval(sol,x); f0 = deval(sol,xa); Cf = (1+(1/L))*f0(3); Nu = - f0(5); Sh = - f0(7);
figure(41); plot(Av,S(2,:),'LineWidth',2); xlabel('\bfA','color','b'); ylabel('\bff^\prime(\eta)','color','b'); hold on,
end
end
Please use the tools in the forum to format your code. This improves the readability.
Why do you expect 3 curves only?
Dear Jan Since I have taken 3 values of the parameter L And variations of A will be in X axis
Dear Jan
This is still unsolved.
Can it be possible for a last try?
I'm not sure, which problem is still open. The code of my answer is running, and only the diagram looks a little bit strange. I do not know, what you want to get instead of this solution. So please explain again, what is still unsolved.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 16 Nov 2021

Commented:

Jan
on 6 Dec 2021

Community Treasure Hunt

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

Start Hunting!