Unrecognized function or variable 'guess_my_number'.

How I can solve the function?
I'm doing the course now and in the lesson number 5 we have a simple exercise with the function called 'guess_my_number', but when I'm trying to use it, Matlab says the next:''Unrecognized function or variable'' or ''Not enough input arguments''. I'm using the free trial of Matlab R2020a.
function guess_my_number(x)
if x == 2
fprintf('Congrats! You guessed my number!\n');
end

 채택된 답변

Adam Danz
Adam Danz 2020년 4월 22일
편집: Adam Danz 2020년 4월 23일
Matlab says the next:''Unrecognized function or variable'' or ''Not enough input arguments''
Those are two unrelated error messages. The first one is telling you that the file containing the function is not on Matlab's path. Use addpath(...) so matlab has access to the file. (see help addpath if needed). Or it might mean that the a variable or function name was misspelled.
The second error message means that Matlab does recognized the file but not enough input arguments were provided. The function looks like it has 1 input so when you call the function from the command window or from another function or script, you need to provide it with a value such as ,
guess_my_number(20)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2020년 4월 22일

편집:

2020년 4월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by