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

3 views (last 30 days)
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

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 21 May 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)

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!