Not enough input arguments?

조회 수: 1 (최근 30일)
Victor Popa-Simil
Victor Popa-Simil 2019년 12월 14일
댓글: Victor Popa-Simil 2019년 12월 14일
I'm trying to make a user-define function that accepts time as an input and gives me an output of height. Here is the code I am using currently.
For some reason it keeps giving me the error on line 2 that I do not have enough input arguments. What does this mean? Thank you!
function h=height(t)
h=(-(9.8/2).*t.^2)+(125.*t)+500;
end

채택된 답변

Image Analyst
Image Analyst 2019년 12월 14일
How are you calling it? What value are you passing in for t? You're not just clicking the green run triangle without giving it a value for t are you? So, let's say t was 10. Are you doing
t = 10;
h = height(t); % Pass in t to the height() function.
fprintf('For t = %.1f, height = %f.\n', t, h);
So, what is your program for calling your height() function? Evidently from the error it thinks you're doing this:
h = height(); % Not passing in anything for t. This will throw an error.
or else you're clicking the green run triangle which will try to run the function without sending in anything for t.
  댓글 수: 1
Victor Popa-Simil
Victor Popa-Simil 2019년 12월 14일
I completely skipped over the fact that I had no value for t and that made the error. Simple mistake. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Mobile Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by