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

1 次查看(过去 30 天)
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

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-5-21
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by