Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 21 Mai 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)

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by