我有一个非常简单的代码如下,
[Y M] = datevec(datenum({'199812';'201203'},'yyyymm'));
% Y returns the # of years,
% M is the # of months other
% than a full year
mns = diff([Y M])*[12;1];
% mns is the total # of months
% between 12/1998 to 03/2012
Monthdate = cellstr(datestr(datenum(1998,12+(0:mns)',1),'yyyymm'));
% Returns cells as
%199812,199901,199902,
%199003,...201203
有时这段代码效果很好。有时会回来,
Error using datenum (line 181)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed on converting date string to date number.
怎么会不稳定?反正是为了让它稳定吗?
答案 0 :(得分:0)
我有完全相同的问题(R2012a) - 它实际上似乎是一个不稳定的功能。每当它开始发生时,我只是重新启动Matlab,它会再次运行一段时间。