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 ExchangeLanguage Fundamentals についてさらに検索

製品

リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by