Solve the error 'not enough input arguments'

3 vues (au cours des 30 derniers jours)
Inti Vanmechelen
Inti Vanmechelen le 20 Déc 2015
Modifié(e) : John D'Errico le 20 Déc 2015
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 commentaires
David Young
David Young le 20 Déc 2015
It would help if you showed the whole error message. You probably also need to show the code that calls the function.
Jan
Jan le 20 Déc 2015
Edited: Code formatted properly.

Connectez-vous pour commenter.

Réponses (2)

Jan
Jan le 20 Déc 2015
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 le 20 Déc 2015
Modifié(e) : John D'Errico le 20 Déc 2015
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

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by