How to convert string to number?

1 visualización (últimos 30 días)
akshatha nayak
akshatha nayak el 6 de Mayo de 2019
Editada: Stephen23 el 6 de Mayo de 2019
we have extracted a value from GUI using
id1=get(handles.id1,'String');
Now i want to check if the value is a number. How do i do this?
If the value is a number that is converted to a string using the above line, how do I convert it back to a number?
  1 comentario
KSSV
KSSV el 6 de Mayo de 2019
Read about ischar, str2num, num2str,

Iniciar sesión para comentar.

Respuestas (1)

Stephen23
Stephen23 el 6 de Mayo de 2019
Editada: Stephen23 el 6 de Mayo de 2019
"...how do I convert it back to a number?"
Convert to numeric:
num = str2double(id1)
"Now i want to check if the value is a number"
isn = ~isnan(num)

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by