Solve the error 'not enough input arguments'

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

回答(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