Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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?

Réponse acceptée

Shaun VanWeelden
Shaun VanWeelden le 19 Avr 2013
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.. ];

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by