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

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
Error using bvp4c (line 196)
Unable to solve the collocation equations -- a singular Jacobian encountered.

Error in solution>trial (line 51)
sol=bvp4c(@odefun,@bcfun,solinit);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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

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.)
That's the screenshot of what i get when running the code online
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
/MATLAB/toolbox/matlab/funfun/bvp4c.m
If you see two such functions listed and one is not in toolbox/matlab/funfun, that is likely the cause.
Thus the screenshot of the full matlab response. I changed the wrapping function name and also the saved files names to avoid conflict. This is the last output after the changes made.
Last screenshot of the suggestion running which... command
P
P on 9 Apr 2026 at 18:13
Edited: P on 9 Apr 2026 at 18:13
So i must erase one of the files? Because i see one is being shadowed
+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).
I moved my comment to be an answer, so that you can "Accept" it as a solution to your question, if you want.

Sign in to comment.

 Accepted Answer

the cyclist
the cyclist on 9 Apr 2026 at 16:08
Moved: the cyclist on 9 Apr 2026 at 18:32
I see in your screenshot that you have a file named BVP4C.m. That should presumably not cause a problem (because MATLAB is case-sensitive). But it makes me wonder if you also have a file named bvp4c.m, that would cause a problem (because it would get called instead of the MATLAB-supplied function of the same name).

6 Comments

Thanks so much i managed to remove the bvp4c.m shadowing file There is no longer toomuch input arguments error i belive this means that what is left is to deal with the actual method implementation and running the file.
So this is the possible reason why bvp4c method was alwys giving toomuch input arguments error in diferent programs?
Yes, this was almost certainly the reason.
> That should presumably not cause a problem (because MATLAB is case-sensitive).
By default the APIs for Windows NTFS file systems are not case sensitive (but are case preserving.) NTFS itself is case sensitive, but the major file creation operating system call defaults to case insensitive. You can configure NTFS access to be case sensitive; see https://www.howtogeek.com/354220/how-to-enable-case-sensitive-folders-on-windows-10/
By default MacOS HFS+ and MacOS APFS are not case sensitive (but are case preserving.) You can configure for case sensitivity at the time of creating the file system. Converting an existing filesystem to change its case sensitivity is a nuisance; https://github.com/cr/MacCaseSensitiveConversion
However, MATLAB Online runs on Linux, and most Linux filesystems are case sensitive.
writelines("test 1", "foo.txt")
writelines("test 2", "FOO.txt")
ls
foo.txt FOO.txt
Any suggestion on the bvp4c so that it can converge?
My suggestion is to open a new question that is focused on that specific issue. You will likely get more people seeing your question, when it is not buried in a comment of a different question.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2024b

Asked:

P
P
on 9 Apr 2026 at 13:46

Edited:

on 10 Apr 2026 at 0:32

Community Treasure Hunt

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

Start Hunting!