Store a variable from prompt user input
Afficher commentaires plus anciens
Hi, I have this function which display a request in the prompt and asks user to input a number. The function then repeats until user inputs a valid number.
function num = inputNumber(prompt)
while true
num = str2double(input('Write your age :', 's'));
if ~isnan(num)
break;
end
end
I want then to store the input in the variable num but it is not happening. Why? How can I solve it? Thanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scope Variables and Generate Names dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!