Problem with datenum usage
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi
I am trying to use the datenum function of matlab to convert into dates I read through the manual in matlab andhave used
Time = datenum(num2str(time),'yyyymmdd');
which works but when i change it to also register the Hours and Minutes in failed
time = A(:,1);
Time = datenum(num2str(time),'yyyymmddHHMN');
S.Time=Time
DATENUM failed.
Error in SWAN2buoy (line 29)
Time = datenum(num2str(time),'yyyymmddHHMN');
Caused by:
Error using cnv2icudf (line 131)
Unrecognized minute format. Format string: yyyymmddHHMN.`
have to say that I am using datenum to read timeseries from a file i have, and i would like to have it it a full timeseries form The original uploaded date format is
2.010010100300000e+07
thank you
댓글 수: 1
Andy L
2014년 8월 8일
Minutes should be 'MM' not 'MN'
채택된 답변
Iain
2014년 8월 8일
0 개 추천
Its a typo:
'yyyymmddHHMN'
MN should be MM
댓글 수: 14
Have tried that as well, and its the same fail
Time = datenum(num2str(time),'yyyymmddHHM');
Error using datenum (line 179)
DATENUM failed.
Error in SWAN2buoy (line 29)
Time = datenum(num2str(time),'yyyymmddHHM');
Caused by:
Error using cnv2icudf (line 131)
Unrecognized minute format. Format string: yyyymmddHHM.
You deleted the ‘N’ but didn’t replace it with an ‘M’.
Try this:
Time = datenum(num2str(time),'yyyymmddHHMM');
As Iain pointed out, there's a typo:
>> datenum('201408081539','yyyymmddHHMM')
ans =
7.3582e+005
You have only one M instead of two.
The initial format of the date is
x =20100101
20100101.0030000
20100101.0100000
20100101.0130000
20100101.0200000
I have tried the
Time = datenum(num2str(x),'yyyymmddHHMM');
but i get the mentioned error
Well, the decimal is new.
The format line has to match the data. See if this works:
Time = datenum(num2str(x),'yyyymmdd.HHMM');
Hello
I tried with the decimal indicator but it does not work either
Time = datenum(num2str(x),'yyyymmdd.HHMM')
Error using datenum (line 179)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed on converting date string to date number.
If x is
x = [20100101;
20100101.0030000;
20100101.0100000;
20100101.0130000;
20100101.0200000]
Can you tell us what the numbers in the decimal places means? The following
Time = datenum(num2str(x(n)),'yyyymmdd.HHMM');
works for n = 1,3, and 5. But it fails for n = 2 and 4, so I guess it has something to do with the format.
Iain
2014년 8월 11일
What values do you have in A(:,1) - I want to see the min & max.
the values after the decimal represent the hours and minutes of the recording
the min is the starting time 20100101.000000 and the end (max) 20101231.180000
I did not upload the whole column so as to save space
Iain
2014년 8월 11일
Ok, I figured it out.
datenum only works on ONE number at a time. Loop through, one element at a time, and it should work.
Time = arrayfun(@(d) datenum(sprintf('%1.6f\n',d),'yyyymmdd.HHMMSS'),x)
George
2014년 8월 11일
@Michael Haderlein, thank you very much this is working .
may i ask why does datenum fails when a large series of number is given to it?
Iain
2014년 8월 11일
It fails when two numbers are given to it. I don't know why.
George
2014년 8월 11일
thank you everybody for your help :) !
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
제품
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
