I am getting the result and graphs of the equation yy1 but not YY2. if I remove the 2nd equation i.e yy2 part then the program is giving result. whenever m adding yy2 part and boundary conditions m getting error.can someone help me?

11 views (last 30 days)
function [y]=wedge_bvp4c
% defining parameters
b=0.4,M=0.4,L=0.7,Pr=0.5,R= 0.5;
sol1 = bvpinit(linspace(0,5,10),[1 0 1 0 1 0]);
sol = bvp4c(@bvp2D,@bc2D,sol1);
x = sol.x;
y = sol.y;
%%% Plotting of the velocity
figure (1)
plot(x, y(2, :) ,'linewidth', 1)
hold on
xlabel('\eta', 'fontweight', 'bold', 'fontsize', 16)
ylabel('f^/(\eta)', 'fontweight', 'bold', 'fontsize', 16)
%% Residual of the boundary conditions
function residual = bc2D(y0, yinf)
residual=[y0(1); y0(2); y0(5)-1; yinf(2)-1; yinf(5)];
end
%% System of First Order ODEs
function yvector = bvp2D(t,y)
yy1 = (1/(1+1/b))*(M*y(2)-y(1)*y(3)-L*(1-y(2)*y(2)));
yy2= (1/(1+R))*Pr*(y(2)*y(5)-y(1)*y(6));
yvector = [y(2);y(3);y(5);y(6);yy1;yy2];
end
end

Answers (2)

Torsten
Torsten on 11 Dec 2025 at 15:03
Moved: Torsten on 11 Dec 2025 at 15:03
You always need as many boundary conditions as you have first-order differential equations. So if you have 6 equations, you need 6 boundary conditions, not 5.

Star Strider
Star Strider on 11 Dec 2025 at 15:10
There is an error somewhere.
According to the error, 'bc2D' '... should return a column vector of length 6.' It is returning a column vector of length 5 instead.
Please change whatever is necessary to let your code run.
wedge_bvp4c
Error using bvparguments (line 103)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT):
The boundary condition function BCFUN should return a column vector of length 6.

Error in bvp4c (line 119)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in solution>wedge_bvp4c (line 11)
sol = bvp4c(@bvp2D,@bc2D,sol1);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function [y]=wedge_bvp4c
% defining parameters
b=0.4;
M=0.4;
L=0.7;
Pr=0.5;
R= 0.5;
sol1 = bvpinit(linspace(0,5,10),[1 0 1 0 1 0]);
sol = bvp4c(@bvp2D,@bc2D,sol1);
x = sol.x;
y = sol.y;
%%% Plotting of the velocity
figure (1)
plot(x, y(2, :) ,'linewidth', 1)
hold on
xlabel('\eta', 'fontweight', 'bold', 'fontsize', 16)
ylabel('f^/(\eta)', 'fontweight', 'bold', 'fontsize', 16)
%% Residual of the boundary conditions
function residual = bc2D(y0, yinf)
residual=[y0(1); y0(2); y0(5)-1; yinf(2)-1; yinf(5)];
end
%% System of First Order ODEs
function yvector = bvp2D(t,y)
yy1 = (1/(1+1/b))*(M*y(2)-y(1)*y(3)-L*(1-y(2)*y(2)));
yy2= (1/(1+R))*Pr*(y(2)*y(5)-y(1)*y(6));
yvector = [y(2);y(3);y(5);y(6);yy1;yy2];
end
end
.

Tags

Community Treasure Hunt

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

Start Hunting!