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?
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!