@MichelJuillard You should not use the constructor in the .mod file. Instead of:
d1=dseries(randn(10,1),dates('-4Y'));
you should write:
d1=dseries(randn(10,1),-4Y);
The preprocessor will replace -4Y by dates('-4Y'). The documentation can certainly be improved but this behaviour is explained in the section about the dates class. We have introduced an escape parameter ($) to avoid the substitution. I am not sure it works as it should in this case. Your example works if I do:
d1=dseries(randn(10,1),dates('-$4Y'));
but I first tried
d1=dseries(randn(10,1),dates('$-4Y'));
which for me makes more sense and unfortunately does not work. So for me the bug is here.
I thought that this behaviour was already here in 4.5.x, I would need to check.
I think it should be possible to allow the call to the constructor in *.mod files... It shouldn't be that hard to match such calls in the preprocessor, and not apply the transformation in such case. @houtanb, Do you have an opinion on this?
To be honest, I think it's funny that we provide the substitution at all in MATLAB statements in the .mod file, as all other MATLAB statements pass through as written by the user.
That said, I will look into not doing the substitution when a we encounter dates(...).
I'll also look into supporting the escape sequence before a - sign as opposed to after.
For positive dates, it is possibles to use dates('2010Y') as it translates to
dates(dates('2010Y'))
that is correct syntax in Matlab
2. When the date is negative, as in dates('-4Y'), it translates to
dates('-dates('4Y')')
It isn't entirely clear where the quotes around '-dates('4Y')' are coming from. Even without the quotes the expression wouldn't give the expected results because of the definition on unitary minus.