Too many input arguments in bvp4c solver MATLAB online version. Help please.
Show older comments

Under boundary condtions:
Take the guess functions to be :

BVP4C code for the problem is :
trial % SL: added call to the function so we can see the error message
function trial
% Global variables declaration
global A M n m Ec Pr gamma Nt Nb GrT GrC Rd Sc Costant
% Parameter initialization
A = 1;
M = 1;
n = 2;
m = 1;
gamma = 1;
Nt = 1;
Nb = 1;
GrT = 1;
GrC = 2;
Rd = 1;
Sc = 1;
Pr = 1;
Ec = 1;
% Constant calculation
Costant = (m*(2*n - 1) + 1) / (n + 1);
% System of ODE
function dydx = odefun(~, y)
dydx = zeros(7, 1);
dydx(1) = y(2);
dydx(2) = y(3);
%Momentum equation
dydx(3) = (m*(y(2))^2 - Costant*y(1)*y(2) - GrT*y(5) - GrC*y(7) + M*y(2)) / (A + n*(-y(3))^(n-1));
dydx(4) = y(6);
%Energy equation
dydx(5) = -(Costant*y(1)*y(6) + Nb*y(7)*y(6) + Nt*(y(6))^2 + Ec*A*(y(3))^2 + Ec*(-y(3))^(n+1) + M*Ec*(y(2))^2) / ((1/Pr)*(1 + (4/3)*Rd));
dydx(6) = y(7);
% Concentration equation
dydx(7) = gamma*y(7) - Sc*Costant*y(1)*y(7) - (Nt/Nb)*y(5);
end
% Nested function: Boundary conditions
function res = bcfun(ya, yb)
res = zeros(7, 1);
res(1) = ya(2); % y(2) = 0 at eta = 0
res(2) = ya(1); % y(1) = 0 at eta = 0
res(3) = ya(5); % y(5) = 0 at eta = 0
res(4) = Nb*ya(7) + Nt*ya(6); % Boundary condition at eta = 0
res(5) = yb(2); % y(2) = 0 at eta = 10
res(6) = yb(5); % y(5) = 0 at eta = 10
res(7) = yb(7); % y(7) = 0 at eta = 10
end
solinit=bvpinit(linspace(0,10,10),[0 0 0 0 0 0 0]);
sol=bvp4c(@odefun,@bcfun,solinit);
eta=linspace(0,10,100);
y=deval(sol,eta);
end
The code is always failing on matlab online version giving the toomany input arguemnts error kindly help my good people.
8 Comments
Steven Lord
on 9 Apr 2026 at 14:41
That's not the error message your code throws when I ran it on Answers. Can you confirm whether you see that error message or a different one when you run it on MATLAB Online? If you receive a different error message, please post the full and exact text of that message (all the red and/or orange text displayed when you run your code.)
P
on 9 Apr 2026 at 15:03
Could you show the line that's just above what you displayed? If @the cyclist is correct (which I suspect they are) the underlined function name will be bvp4c. The fact that the underline is pierced by a descender in about the right place for the "p" in "bvp4c" is suggestive.
If it is, please show us the output of this command run in your MATLAB Online session:
which -all bvp4c
If you see two such functions listed and one is not in toolbox/matlab/funfun, that is likely the cause.
P
on 9 Apr 2026 at 18:04
P
on 9 Apr 2026 at 18:12
Cris LaPierre
on 9 Apr 2026 at 18:15
Edited: Cris LaPierre
on 9 Apr 2026 at 18:16
+1 to @the cyclist. You have 2 files named bvp4c.m. Your local file has precedence over the MathWorks function, as indicated by the % Shadowed comment following it. Your file is either a script, or a function with a different number of inputs.
Rename your local file to something unique (the one at /MATLAB Drive/bvp4c.m).
the cyclist
on 9 Apr 2026 at 18:34
Edited: the cyclist
on 9 Apr 2026 at 19:07
I moved my comment to be an answer, so that you can "Accept" it as a solution to your question, if you want.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


