Is it possible to change a double with exonents so no exp or decimal?

1 次查看(过去 30 天)
I am trying to change dates in cells in the form [19861001010000] (yyyy mm dd hh mmmm) to a number that I can parse into the year, month, etc. I used G = [cellfun(@str2num,Date(:,1))]; because I had a column of cell dates after using textscan to import data. This gave me a column of numbers in exponential notation (eg. 1.9861e+13). In order to parse this number I need this column to be whole numbers, I think (eg. 19861001010000). And then I plan to extract the year, month etc. to make a graph. Any advice about how I should approach this?

采纳的回答

Shaun VanWeelden
Shaun VanWeelden 2013-4-19
OK, I would absolutely leave it as a string until it is finished parsing!
The 1.9861e+13 still represents all values by the way, but that doesn't matter in this approach.
I would just do something like str='19861001010000'
year=str(1:4);year=str2double(year);
OR more compact
month=str2double(str(5:6));
the idea being you simply convert one portion of your date at a time to a double value.
Instead of making 6 variables, you can also do date(1)=year; date(2)=month, etc. or just do:
date=[ str2double(str(1:4)) str2double(str(5:6)) etc.. ];

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by