I keep getting undefined input error

Hello , im trying to make this gpa/cgpa calculator that asks the user for input , but whenever i reach the the input that requires a character it shows undifined error as shown in the screenshot :
Enter letter grade for course: A
Error using input
Undefined function or variable 'A'.
Error in Untitled11 (line 10)
Grade = input('Enter letter grade for course: ');

回答(1 个)

hello
you want to request a string not a number , so the correct code is :
Grade = input('Enter letter grade for course: ',"s");

4 个评论

Error using input
The second argument to INPUT must be 's'.
Error in Untitled11 (line 10)
grade = input('Enter letter grade for course: ',"s");
ok
this can be due to which release you are working with (I have R2020b)
so look for the help of the function and correct if needed
i use R2018a , will check help of the function , thank you.
Try using single quotes for 's', similar to what you did for Course.
Grade = input('Enter letter grade for course: ','s');

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Testing Frameworks 的更多信息

产品

版本

R2018a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by