How number character array to single number conversion can be performed?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
JOSHY T R
el 21 de Mayo de 2014
Comentada: JOSHY T R
el 21 de Mayo de 2014
Sir,
>> Z_data=data(1,52:63)
Z_data =
-008.5710001
It's my data to be converted to single number. I performed following tasks:
>> Z_data_str = mat2str(Z_data)
Z_data_str =
'-008.5710001'
Here I converted the number character array to a string
>> Z_data_num = str2num(Z_data_str)
Z_data_num =
[]
Here I tried to convert the that the string to number, but I get a [] symbol. why did it so?
>> Z_data_num = str2double(Z_data_str)
Z_data_num =
NaN
And when I tried to convert it to double type the answer was NaN. Please explain the reasons to both the results. And suggest a solution.
Thanks
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 21 de Mayo de 2014
Z_data ='-008.5710001'
%Z_data is already a char type
Z_data_num=str2num(Z_data)
In your case by adding
Z_data_str=mat2str(Z_data)
you created a new string containing quotes ' ', you can check the sizes of
size(Z_data)
size(Z_data_str)
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!