Error using input Cannot call INPUT from EVALC.

11 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 4 Feb 2022
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.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!