Problem with monthly datetime array (calmonths)
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody, I am facing some strange problem when I want to create a monthly datetime array. When I start matlab and create a monthly datetime vector as shown here: https://de.mathworks.com/help/matlab/ref/ymd.html with following command
t = datetime(2013,05,31):calmonths(3):datetime(2014,06,15)
everything is fine and it produes the vector including 5 months. Afterwards I was running a script and then I tried to produce following monthly datetime array
calperiodmon=datetime(2011,01,01):calmonths:datetime(2014,12,31);
Then the error "Inputs must be scalar" occured, but I have several codes where exactly that expression is working. To check what was wrong I tried to get the output of the example mentioned before (t array above) and now it produces a 1x381 array containing each day instead of the months. Trying to get my desired output in this way:
calperiodmon=datetime(2011,01,01):calmonths:datetime(2014,12,31);
now also results in an 1x1461 array that comrpises all days of the period of interest instead of months.
I am confused, if I restart Matlab and directly produce my monthly array it works, but always after running the script and try to produce similar arrays afterwards it behaves as described above. Sure it is an option to go ahead like that and always restart matlab before running my code(s) but I would say that it is not really satisfying.
Hopefully, some of you could help me since I really have no clue what's going on :)
Greetings and thanks in advance
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!