How number character array to single number conversion can be performed?

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 21 Mag 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)

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by