Problem with datenum usage
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 日
Its a typo:
'yyyymmddHHMN'
MN should be MM
14 件のコメント
George
2014 年 8 月 8 日
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.
Star Strider
2014 年 8 月 8 日
You deleted the ‘N’ but didn’t replace it with an ‘M’.
Try this:
Time = datenum(num2str(time),'yyyymmddHHMM');
Michael Haderlein
2014 年 8 月 8 日
As Iain pointed out, there's a typo:
>> datenum('201408081539','yyyymmddHHMM')
ans =
7.3582e+005
You have only one M instead of two.
George
2014 年 8 月 8 日
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
Star Strider
2014 年 8 月 8 日
Well, the decimal is new.
The format line has to match the data. See if this works:
Time = datenum(num2str(x),'yyyymmdd.HHMM');
George
2014 年 8 月 11 日
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.
Hikaru
2014 年 8 月 11 日
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.
Michael Haderlein
2014 年 8 月 11 日
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 についてさらに検索
製品
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
