Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
1d3dc377
Commit
1d3dc377
authored
Mar 14, 2013
by
Stéphane Adjemian
Browse files
Allow declaration of dates with lowercase frequencies.
parent
f3f985dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
matlab/@dynDate/dynDate.m
View file @
1d3dc377
...
...
@@ -60,8 +60,6 @@ function date = dynDate(a,b)
%
You
should
have
received
a
copy
of
the
GNU
General
Public
License
%
along
with
Dynare
.
If
not
,
see
<
http
:
//www.gnu.org/licenses/>.
%
Original
author
:
stephane
DOT
adjemian
AT
univ
DASH
lemans
DOT
fr
date
=
struct
;
date
.
freq
=
NaN
;
...
...
@@ -75,6 +73,7 @@ switch nargin
return
case
1
if
ischar
(
a
)
%
Weekly
,
Monthly
or
Quaterly
data
.
a
=
upper
(
a
);
if
length
(
a
)
>
1
quaterly
=
findstr
(
'Q'
,
a
);
monthly
=
findstr
(
'M'
,
a
);
...
...
@@ -154,8 +153,8 @@ end
%
$
%
Define
some
dates
%
$
date_1
=
1950
;
%
$
date_2
=
'
1950
Q2
'
;
%
$
date_3
=
'
1950
M
10
'
;
%
$
date_4
=
'
1950
W
50
'
;
%
$
date_3
=
'
1950
m
10
'
;
%
$
date_4
=
'
1950
w
50
'
;
%
$
date_5
=
'
1950
'
;
%
$
%
$
%
Define
expected
results
.
...
...
@@ -222,4 +221,20 @@ end
%
$
t
(
1
)
=
1
;
%
$
end
%
$
T
=
all
(
t
);
%
@eof
:
3
\ No newline at end of file
%
@eof
:
3
%
@test
:
4
%
$
%
Instatiate
an
empty
objects
for
quaterly
,
monthly
and
weekly
dates
.
%
$
qq
=
dynDate
(
'q'
);
%
$
mm
=
dynDate
(
'm'
);
%
$
ww
=
dynDate
(
'w'
);
%
$
%
$
%
Check
the
results
.
%
$
t
(
1
)
=
dyn_assert
(
qq
.
freq
,
4
);
%
$
t
(
2
)
=
dyn_assert
(
mm
.
freq
,
12
);
%
$
t
(
3
)
=
dyn_assert
(
ww
.
freq
,
52
);
%
$
t
(
4
)
=
dyn_assert
(
all
(
isnan
(
qq
.
time
)),
1
);
%
$
t
(
5
)
=
dyn_assert
(
all
(
isnan
(
mm
.
time
)),
1
);
%
$
t
(
6
)
=
dyn_assert
(
all
(
isnan
(
ww
.
time
)),
1
);
%
$
T
=
all
(
t
);
%
@eof
:
4
matlab/@dynSeries/dynSeries.m
View file @
1d3dc377
...
...
@@ -59,7 +59,7 @@ function ts = dynSeries(varargin)
%!
@end
deftypefn
%
@eod
:
%
Copyright
(
C
)
2011
,
2012
Dynare
Team
%
Copyright
(
C
)
2011
,
2012
,
2013
Dynare
Team
%
%
This
file
is
part
of
Dynare
.
%
...
...
@@ -76,8 +76,6 @@ function ts = dynSeries(varargin)
%
You
should
have
received
a
copy
of
the
GNU
General
Public
License
%
along
with
Dynare
.
If
not
,
see
<
http
:
//www.gnu.org/licenses/>.
%
AUTHOR
(
S
)
stephane
DOT
adjemian
AT
univ
DASH
lemans
DOT
fr
ts
=
struct
;
ts
.
data
=
[];
...
...
@@ -143,26 +141,8 @@ switch nargin
%
Get
the
first
date
and
set
the
frequency
.
if
~
isempty
(
b
)
if
ischar
(
b
)
%
Weekly
,
Monthly
or
Quaterly
data
.
quaterly
=
findstr
(
'Q'
,
b
);
monthly
=
findstr
(
'M'
,
b
);
weekly
=
findstr
(
'W'
,
b
);
yearly
=
findstr
(
'Y'
,
b
);
if
~
isempty
(
quaterly
)
ts
.
freq
=
4
;
end
if
~
isempty
(
monthly
)
ts
.
freq
=
12
;
end
if
~
isempty
(
weekly
)
ts
.
freq
=
52
;
end
if
~
isempty
(
yearly
)
ts
.
freq
=
1
;
end
if
isempty
(
quaterly
)
&&
isempty
(
monthly
)
&&
isempty
(
weekly
)
&&
isempty
(
yearly
)
error
(
'
dynSeries
::
Using
a
string
as
a
second
input
argument
,
I
can
only
handle
weekly
(
W
),
monthly
(
M
),
quaterly
(
Q
)
or
yearly
(
Y
)
data
!
'
);
end
ts
.
init
=
dynDate
(
b
);
ts
.
freq
=
ts
.
init
.
freq
;
elseif
isa
(
b
,
'
dynDate
'
)
&&
~
isempty
(
b
)
ts
.
freq
=
b
.
freq
;
ts
.
init
=
b
;
...
...
@@ -354,7 +334,7 @@ ts.time = ts.init:(ts.init+ts.nobs);
%
$
t
=
zeros
(
7
,
1
);
%
$
%
$
try
%
$
ts
=
dynSeries
([
transpose
(
1
:
5
),
transpose
(
6
:
10
)],
'
1950
Q
1
'
,{
'
Output
'
;
'
Consumption
'
},
{
'
Y_t
'
;
'
C_t
'
});
%
$
ts
=
dynSeries
([
transpose
(
1
:
5
),
transpose
(
6
:
10
)],
'
1950
q
1
'
,{
'
Output
'
;
'
Consumption
'
},
{
'
Y_t
'
;
'
C_t
'
});
%
$
t
(
1
)
=
1
;
%
$
catch
%
$
t
=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment