フィルターのクリア

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

1 回表示 (過去 30 日間)
Ryan Dillingham
Ryan Dillingham 2013 年 4 月 19 日
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 Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by