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
답변 (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.
댓글 수: 0
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?
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!