why this message( Not enough input arguments.)
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
function y_array=x1(a)
y_array=[];F=0.1;
for i=1:length(a)
n=a(i);
if (-1/(2*F)<=n)&&(n<=1/(2*F))
y=cos(2*pi*F*n);
end
y=0;
end
y_array=[y_array y];
[SL: applied code formatting]
1 commentaire
Réponses (2)
At a wild guess you are just clicking the big green 'Run' button to run your code.
Your function takes an argument though so I would assume that you would want to pass this in i.e. call the function on command line or from another function as e.g.
x1(7);
I'm always surprised the number of times in a week this question gets asked. It's not that it is a stupid question, per se, just that I don't get how people have a function that they have written to work on an input and yet they don't seem to at all think about the fact that they need to pass in that argument. What do you expect the code to do if you don't give it that parameter to act upon?! I guess it comes from people upgrading from using scripts to using functions and having a variable named 'a' in the workspace.
Jan
le 22 Mar 2017
0 votes
I guess, that you start this function using the green arrow in the editor? Then the input argument a is missing. Or do you call it from the command line without input arguments?
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!