MATLAB: How to solve the error “Not enough input arguments.”

input argumentsode45

how to solve the error "Not enough input arguments."
i have saved file as fick.m
function dydt = Fick(t,C,V,Ji,Je,J2i,J2e,tmax,Cinit)
dydt = (Ji(t,C)-Je(t,C)+J2i(t,C)-J2e(t,C))./V;
end
below file as practical.m
%%One Compartmental Model
clear all
clf % comment out if you want to use the increment tool
% set parameter values
V = 500; % litres water
Cin = 0.2; % mg chemical per litre water
Qi = 50; % litres of water per day
Qe = Qi; % equal volume flow rate
Cinit = 0; % no chemical in tank at time 0
tmax = 30; % time range over which to solve model (days)
% solve the differential equation
sol = ode45(@Fick,[0 tmax],Cinit,[],V,Ji,Je,J2i,J2e);
tstep = 0.01;
tspan = 0:tstep:tmax;
y = deval(sol,tspan);
plot(tspan,y)
xlabel('time (days)');
ylabel('Concentration (mg/l)');
*but i am getting following error..*
Error using Fick (line 2)
Not enough input arguments.

Best Answer

When you pass a function handle to ode45, ode45 is only going to provide the first two input arguments (t and y). If you want to provide additional input arguments you need to use an anonymous function.
You can convert this line:
sol = ode45(@Fick,[0 tmax],Cinit,[],V,Ji,Je,J2i,J2e);
Into something like this:
CallFick = @(t,C) Fick(t,C,V,Ji,Je,J2i,J2e,tmax,Cinit);
sol = ode45(CallFick,[0 tmax],Cinit);
Note: I'm not completely sure 'C' is your dependent variable, or the usage of 'Cinit', so you may need to tweak this syntax a bit to get it to do what you want, but this is the general idea.
You can find more details on the Parameterizing Functions doc page under the heading "Parameterizing Using Anonymous Functions".