I keep getting undefined input error
Show older comments
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: ');

Answers (1)
Mathieu NOE
on 10 May 2022
hello
you want to request a string not a number , so the correct code is :
Grade = input('Enter letter grade for course: ',"s");
4 Comments
rak crak
on 10 May 2022
Mathieu NOE
on 10 May 2022
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
rak crak
on 10 May 2022
Cris LaPierre
on 10 May 2022
Edited: Cris LaPierre
on 10 May 2022
Try using single quotes for 's', similar to what you did for Course.
Grade = input('Enter letter grade for course: ','s');
Categories
Find more on Testing Frameworks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!