Solve the error 'not enough input arguments'

조회 수: 2 (최근 30일)
Inti Vanmechelen
Inti Vanmechelen 2015년 12월 20일
편집: John D'Errico 2015년 12월 20일
Hi guys, Anyone who can explain why I get the error 'not enough input arguments' in this function?
function[EMGNor] = findEMGNor(SmoothSignal,subjects,motion,EMGMax)
for i = 1:10
for k = 1:3
EMGNor.(subjects{i}).(motion{k}) = ...
SmoothSignal.(subjects{i}).(motion{k})(:,2:21) / (EMGMax.(subjects{i}));
end
end
end
I taught I defined all the input arguments I used.
Thank you
  댓글 수: 2
David Young
David Young 2015년 12월 20일
It would help if you showed the whole error message. You probably also need to show the code that calls the function.
Jan
Jan 2015년 12월 20일
Edited: Code formatted properly.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2015년 12월 20일
Let me guess: How do you call this function? Does the call contain all 4 input arguments?
EMGNor = findEMGNor(SmoothSignal, subjects, motion, EMGMax)

John D'Errico
John D'Errico 2015년 12월 20일
편집: John D'Errico 2015년 12월 20일
Just because you define a variable in the base workspace, does not mean it will be automatically passed into the function when you "run" it. This is not how functions work. For example, mean is a function in MATLAB, provided by TMW.
Look at the help for mean.
help mean
mean Average or mean value.
S = mean(X) is the mean value of the elements in X if X is a vector.
For matrices, S is a row vector containing the mean value of each
column.
So mean takes an argument X, and computes the mean. I'll define avariable called X. See what happens.
X = rand(1,10);
run mean
Not enough input arguments.
Error in mean (line 66)
[flag, omitnan] = parseInputs(flag, flag2, isFlag2Set);
Error in run (line 96)
evalin('caller', [script ';']);
Similarly, if I just type the command mean on the command line, it will again fail.
mean
Not enough input arguments.
Error in mean (line 66)
[flag, omitnan] = parseInputs(flag, flag2, isFlag2Set);
In fact, in order to compute the mean of a variable, you need to use it like this:
mx = mean(X)
mx =
0.62386
In fact, you can compute the mean of any array, NOT just an array called X.
mean(1:10)
ans =
5.5

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by