I have two input from user, the first input is receive name(string), the second is receive calorie(numeric). But sometimes user input a string to the second input, how i can handle the error from default matlab using my customize error message?
nama = input("Input your name: ", 's');
kal = input("Input your maximum calories: ");
if(~isnumeric(kal))
msg = "Error: Please input numeric to calorie");
error(msg);
end
But the result is always default error message from matlab,
Error using input
Unrecognized function or variable 'q'.
Error in main (line 5)
kal = input("Input your maximum calories: ");
Error in app (line 5)
[nama, kal] = main();