フィルターのクリア

is this a matlab bug?

1 回表示 (過去 30 日間)
b
b 2013 年 11 月 22 日
コメント済み: Fox 2014 年 1 月 27 日
when i write like:
n = datenum('2017-06-12','yyyy-mm-dd',1900);
n = datenum('2017-06-12','yyyy-mm-dd',2000).
it return the same result.
the matlab version is r2013b.
what's the problem?

採用された回答

David Sanchez
David Sanchez 2013 年 11 月 22 日
The pivot year is used in interpreting date strings that have the year specified as two characters. To see the difference, introduce the last two digits of your your year, otherwise, the use of pivotyear yields the same result.
>> n1 = datenum('17-06-11','yy-mm-dd',1900)
n1 =
700332
>> n2 = datenum('17-06-11','yy-mm-dd',2000)
n2 =
736857
  2 件のコメント
b
b 2013 年 11 月 25 日
編集済み: b 2013 年 11 月 25 日
hi, David. Thanks for your kindly response. I have made some mistake. the code shoulde be
n = datenum('2017-06-12','yyyy-mm-dd',1900);
n = datenum('2017-06-12','yyyy-mm-dd',2000);
they return the same result.
Fox
Fox 2014 年 1 月 27 日
the two statements you have are the same: you have specified the full year '2017'. David specifies only the 3 and 4 characters, '17'. thus Matlab doesn't know if it's 2017 or 1917.
Took me way too long, but I finally found a way to navigate around this; I had data from about 1954 to now... so I wanted some pivot years as 1900 and some as 2000, and the data is not (and should not be) sorted. I told everything that the pivot year was 2000, so that I had a lot of "2054"'s etc.
m = datenum(datestamp,2000)
then in the next statement
datenum(m(m>datenum(now),:),1900);
setting values of m which are greater than today back to 1900. obviously if you have a 1912 or something, though, this would not be ok.
would love a good solution. i think i'm not seeing the tree from the forest anymore on this...

サインインしてコメントする。

その他の回答 (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