Declaration of Variables
Mostrar comentarios más antiguos
Does adding "Num" to a variable ensure that variable input from the user is a number?
1 comentario
the cyclist
el 6 de Oct. de 2011
I am not sure what you mean by "adding Num". Can you give an example of your syntax?
Are you talking about keyboard input [e.g the input() function]? That is going to be a string, and you need to convert to a number and put in safeguards for the input.
Respuestas (1)
Sean de Wolski
el 6 de Oct. de 2011
No. It does not. If the input is a string you could convert it to a number and check and see e.g.
x = '3';
is_x_a_number = isnan(str2double(x))
Then if x can't be converted it'll fail, try:
x = 'hello world'
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!