Error using input Cannot call INPUT from EVALC.

After running the code the correct output is shown in the command window. However, when I try to publish as PDF this error occurs:
Error using input
Cannot call INPUT from EVALC.
Error in LLAB002 (line 48)
numericGrade = input('Enter Numeric Grade(0 to 100): ');
Here is my code
numericGrade = input('Enter Numeric Grade(0 to 100): ');
characterGrade = getCharacterGrade(numericGrade);
fprintf('Grade in Character: %c\n', characterGrade);
function characterGrade = getCharacterGrade(numericGrade)
if numericGrade>=90 && numericGrade<=100
characterGrade = 'A';
elseif numericGrade>=80 && numericGrade<90
characterGrade = 'B';
elseif numericGrade>=70 && numericGrade<80
characterGrade = 'C';
elseif numericGrade>=60 && numericGrade<70
characterGrade = 'D';
else
characterGrade = 'F';
end
end

 채택된 답변

Walter Roberson
Walter Roberson 2022년 2월 4일

1 개 추천

This is a limitation of the technology used to publish().
In order to get around it, you would have to have a function named input on your MATLAB path that displayed the prompt and then returned a fixed value instead of asking the user for the value.
You should consider making a function that takes the numeric grade as input instead.

추가 답변 (0개)

카테고리

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

제품

릴리스

R2021b

질문:

2022년 2월 4일

답변:

2022년 2월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by