From 1e94b6f60b0f0ab858196b8429c2fd04fcc91525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= <stephane.adjemian@univ-lemans.fr> Date: Mon, 2 Dec 2013 08:55:02 +0100 Subject: [PATCH] Added remark about dates in mod files and the $ escape parameter. (cherry picked from commit 4bcf081292730783332713f0b9d1430e2cbd7022) --- doc/dynare.texi | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 4a2c7c9c46..bca432f02a 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -77,8 +77,6 @@ @emph{Algorithms} @end macro - - @macro customhead{title} @iftex @sp 1 @@ -8510,7 +8508,34 @@ Tests if a @dates object follows another @dates object or is equal to this objec @end table -@noindent One can select an element, or some elements, in a @dates object as he would extract some elements from a vector in Matlab/Octave. Let @code{a = 1950Q1:1951Q1} be a @dates object, then @code{a(1)==1950Q1} returns @code{1}, @code{a(end)==1951Q1} returns @code{1} and @code{a(end-1:end)} selects the two last elements of @code{a} (by instantiating the @dates object @code{[1950Q4, 1951Q1]}). +@noindent One can select an element, or some elements, in a @dates object as he would extract some elements from a vector in Matlab/Octave. Let @code{a = 1950Q1:1951Q1} be a @dates object, then @code{a(1)==1950Q1} returns @code{1}, @code{a(end)==1951Q1} returns @code{1} and @code{a(end-1:end)} selects the two last elements of @code{a} (by instantiating the @dates object @code{[1950Q4, 1951Q1]}). + +@remarkhead +@noindent Dynare substitues any occurence of dates in the mod file into an instantiation of the @dates class regardless of the context. For instance, @code{d = 1950Q1;} will be translated as @code{a = dates('1950Q1');}. This automatic substitution can lead to a crash if a date is defined in a string. Typically, if the user wants to display a date: + +@example +disp('Initial period is 1950Q1'); +@end example + +@noindent Dynare will translate this as: + +@example +disp('Initial period is dates('1950Q1')'); +@end example + +@noindent which will lead to a crash because this expression is illegal in Matlab. For this situation, Dynare provides the @code{$} escape parameter. The following expression: + +@example +disp('Initial period is $1950Q1'); +@end example + +@noindent will be translated as: + +@example +disp('Initial period is 1950Q1'); +@end example + +@noindent in the generated matlab script. @node dates class @subsection dates class -- GitLab