why this message( Not enough input arguments.)

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

Jan
Jan 2017년 3월 22일
편집: Jan 2017년 3월 22일
Please post the complete error message. Otherwise the readers have to guess, where the problem occurres.

답변 (2개)

Adam
Adam 2017년 3월 22일
편집: Adam 2017년 3월 22일

1 개 추천

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
Jan 2017년 3월 22일

0 개 추천

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?

이 질문은 마감되었습니다.

질문:

2017년 3월 22일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by