MATLAB: Loop for bvp4c function with an unknown parameter

I tried to solve sixth order differential equation using bvp4c with an unknown parameter “S” and one variable parameter “k”. I have written a subroutine as a bvp4c and a main function for “k”.
The main code is written as follows:
function [] = main()
kk=0.5 ;
for i=1:60
k=kk;
valuePresentstudy = Surfactant(k);
kk=kk+0.1;
end
end
The bvp4c subroutine is written as follows:
function valuePresentstudy = Surfactant(k)
options = bvpset('NMax',100000);
S=0.28;
solinit = bvpinit(linspace(0,1,100),[0.1 0 0 0 0 0],S);
sol = bvp4c(@(x,y)fourode(x,y,k),@(ya,yb)fourbc(ya,yb,k),solinit,options);
save hatimsol.mat sol
x = linspace(0,1);
y = deval(sol,x);
valuePresentstudy=y;
%
function dydx = fourode(x,y,S,k)
Pr=10;
dydx = [ y(2); y(3); y(4); -(k^4+(S/Pr)*k^2)*y(1)+(2*(k^2)+(S/Pr))*y(3); y(6); (k^2+S)*y(5)-y(1)];
%
function res = fourbc(ya,yb,S,k)
e=0;
res = [ ya(1); ya(2); ya(5); yb(1); yb(6)+e*k*yb(5); yb(5)-1; yb(6)];
The error is given as:
Error using Surfactant>@(x,y)fourode(x,y,k)
Too many input arguments.
Error in bvparguments (line 105)
testODE = ode(x1,y1,odeExtras{:});
Error in bvp4c (line 130)
bvparguments(solver_name,ode,bc,solinit,options,varargin);
Error in Surfactant (line 5)
sol = bvp4c(@(x,y)fourode(x,y,k),@(ya,yb)fourbc(ya,yb,k),solinit,options);
Error in MainPresentSurfactant (line 6)
valuePresentstudy = Surfactant(k);
Could you please tell me where my mistake is?
Thanks in advance for your help.

Best Answer

Maybe
sol = bvp4c(@(x,y,S)fourode(x,y,S,k),@(ya,yb,S)fourbc(ya,yb,S,k),solinit,options);
Otherwise pass k to fourode and fourbc as global.
Best wishes
Torsten.