Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
特定の日付から 21 か月を減算する必要があります。
以下に示す私の解決策は、指定された年の最初の月にのみ私を連れて行きます:(
[a,b,c]= datevec(date); b= b-21; datestr(datenum(a,b,c)) %--> 11-Jan-2011 (WRONG).
答えは 2009 年 6 月 11 日にしてほしい。
日付ベクトルではなく日付番号を使用して、次を使用しますaddtodate。
addtodate
>> d = datenum(date); >> e = addtodate(d, -21, 'month'); >> datestr(e) ans = 11-Jun-2009