Invalid default value for property 'MonthsOfYear' in class 'datetime'

The datetime function has recently started giving me the following error, and I can't figure out what the problem might be. Even code that previously worked without problem is now broken. I've tried deleting and re-installing Matlab, but nothing has helped. Needless to say, all functions that depend on datetime are also broken.
If anyone could offer any suggestions it would be appreciated.
Screenshot 2018-11-18 19.22.45.png

6 Comments

experiment with using
restoredefaultpath; rehash toolboxcache
Which release?
What does
which datetime
return?
Sounds like something has gotten munged, somehow.
Thank you so much for the replies. I just discovered that the program folder I had been forwarded contained a script titled 'settings.m'. That was enough to cause a whole host of problems--with the problem I posted about being perhaps the least amongst them. Something had definitely gotten 'munged'!
Ah, yes! There are many possible default settings one could fool with...would be interesting to see what the content of that settings.m file might have contained. I suppose for special purposes there might be reasons to fiddle with some of the internals, but perhaps it was just somebody trying to be too clever by half, maybe??
The 'settings.m' file was just being used by the author of the code to declare some parameters, and wasn't even being used by the time the code got to me. Simply having a file with the name 'settings.m' in my working directory was enough to cause Matlab to throw a fit.
For reference here's the content of the offending script:
function [mspec,mprior,dataset,dates] = settings
%% choose model
mspec = 101;
%% choose prior
mprior = 2;
%% choose dataset
dataset = 902.1;
%% choose date
dates = 2002.25;
As you can see, there's nothing in the content that seems obvioiusly problematic. When this file is present in the working directory, however, Matlab suddenly becomes unable to associate the fields of structures with those structures--which then basically causes everything to break.
Ah, yes. That way would alias the builtin _settings.m_
>> which settings
C:\...\toolbox\matlab\configtools\settings.m
>>
which would really wreak havoc I can see. One generally doesn't think of such things altho there are documented ways to set particular preferences, when one tries to get too clever or stumbles over a naming conflict unawares, bad things are easily caused to happen.
Glad to know what the real deal turned out to be and not difficult to solve once uncovered...also something to file away in the "strange symptom what to look for" column.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2017b

Tags

Asked:

on 19 Nov 2018

Commented:

dpb
on 19 Nov 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!