Error "not enough input arguments"

9 views (last 30 days)
Hi all, I'm new to MatLab and I copied a function from the website here:
To attempt and solve a problem.
This is my code:
function dc = test(t,c)
k1 = 55.2;
k2 = 30.2;
dc = zeros(3,1);
dc(1) = -k1*c(1)^(1/2)*c(2) - k2*c(3)*c(1)^(1/2);
dc(2) = -k1*c(2)*c(1)^(1/2);
dc(3) = k1*c(2)*c(1)^(1/2) - k2*c(3)*c(1)^(1/2);
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
[T,C] = ode45(@test,[0 1],[0.021 0.0105 0.5],options);
plot(T,C(:,1),'-',T,C(:,2),'-.',T,C(:,3),'.')
The error is:
Error using test (line 5)
Not enough input arguments.
Can anyone help?
  3 Comments
Rohan Shaju
Rohan Shaju on 27 Mar 2018
Please help.Not enough input arguments error!

Sign in to comment.

Accepted Answer

Mischa Kim
Mischa Kim on 23 Nov 2014
Thomson, restructure your code in the following way. Put both functions in the same m-file and save it under the same name as the "main" function, my_ode.m, in this case.
function my_ode()
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
[T,C] = ode45(@test,[0 1],[0.021 0.0105 0.5],options);
plot(T,C(:,1),'-',T,C(:,2),'-.',T,C(:,3),'.')
end
function dc = test(t,c)
k1 = 55.2;
k2 = 30.2;
dc = zeros(3,1);
dc(1) = -k1*c(1)^(1/2)*c(2) - k2*c(3)*c(1)^(1/2);
dc(2) = -k1*c(2)*c(1)^(1/2);
dc(3) = k1*c(2)*c(1)^(1/2) - k2*c(3)*c(1)^(1/2);
end
  3 Comments
Abu kamara
Abu kamara on 26 Mar 2020
Please help.Not enough input arguments error!
function fixedNormal = surfaceNormalImpl(fixedNormal)
% Use 6 neighboring points to estimate a normal vector. You may use
% pcnormals with customized parameter to compute normals upfront
fixed.Normal = surfaceNormalImpl(fixedNormal,idx);
fixedNormal = [fixed.Normal(validPtCloudIndices), ...
fixed.Normal(validPtCloudIndices + fixedCount), ...
fixed.Normal(validPtCloudIndices + fixedCount * 2)];
end
Walter Roberson
Walter Roberson on 27 Mar 2020
MATLAB thinks you are trying to run the function by itself without passing in any parameters. You cannot just press the green Run button to run that function: you must pass in a single parameter.

Sign in to comment.

More Answers (3)

Image Analyst
Image Analyst on 22 Nov 2014
You forgot to include the error message - you just snipped out a tiny part of it and did not tell us the crucial parts. Please read this. And include all the red text (not just part of it, so we'll know what line 5 actually is), and tell us how you called this function, for example what values for t and c did you pass in?
By the way, you didn't just click the green triangle without providing any input arguments whatsoever, did you???
  5 Comments
Image Analyst
Image Analyst on 22 Nov 2014
What did you pass in for c? Evidently you passed in just a single number, not an array, so there is no c(2) or c(3).
Thomson
Thomson on 23 Nov 2014
I've tried some vectors such as
[0 0 0]
and now I'm experiencing this error:
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to
change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in odeset

Sign in to comment.


Deeksha kaila
Deeksha kaila on 2 Oct 2017
Edited: Walter Roberson on 2 Oct 2017
Hello, I typed a function
Function y=lf(x)
Y=log(1-exp(-1/x))
Bt it displays an error 'Not enough input arguments'. Please help me to run this function.
  2 Comments
Walter Roberson
Walter Roberson on 2 Oct 2017
You need to invoke the routine at the command line and pass in a value. For example,
lf(2.334320)
Jan
Jan on 2 Oct 2017
@Deeksha kaila: Please do not append a new question to an existing thread. This is the section for answers and such "thread hijacking" confuses the readers. Thanks.

Sign in to comment.


Sowmitha Sangi
Sowmitha Sangi on 29 Nov 2020
function F = SpectralFlux(signal,windowLength, step, fs)
signal = signal / max(abs(signal));
curPos = 1;
L = length(signal);
numOfFrames = floor((L-windowLength)/step) + 1;
H = hamming(windowLength);
m = [0:windowLength-1]';
F = zeros(numOfFrames,1);
for (i=1:numOfFrames)
window = H.*(signal(curPos:curPos+windowLength-1));
FFT = (abs(fft(window,2*windowLength)));
FFT = FFT(1:windowLength);
FFT = FFT / max(FFT);
if (i>1)
F(i) = sum((FFT-FFTprev).^2);
else
F(i) = 0;
end
curPos = curPos + step;
FFTprev = FFT;
end
  2 Comments
Sowmitha Sangi
Sowmitha Sangi on 29 Nov 2020
can anyone help me with this :
error: SpectralFlux
Not enough input arguments.
Error in SpectralFlux (line 2)
signal = signal / max(abs(signal));
Walter Roberson
Walter Roberson on 30 Nov 2020
95% of the time when someone posts something like this, it is because they have pressed the big green Run button to run the code, instead of going down to the command line and invoking the code passing in parameters.
If you press the big green Run button, MATLAB will not look inside the base workspace to find definitions for signal, windowLength, step, or fs: MATLAB relies strictly on the values passed in positionally.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!