/usr/share/doc/dynare/dynare.html/Dates.html is in dynare-doc 4.5.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1996-2017, Dynare Team.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license can be found at http://www.gnu.org/licenses/fdl.txt. -->
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Dates (Dynare Reference Manual)</title>
<meta name="description" content="Dates (Dynare Reference Manual)">
<meta name="keywords" content="Dates (Dynare Reference Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2any">
<link href="index.html#Top" rel="start" title="Top">
<link href="Command-and-Function-Index.html#Command-and-Function-Index" rel="index" title="Command and Function Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Time-Series.html#Time-Series" rel="up" title="Time Series">
<link href="dseries-class.html#dseries-class" rel="next" title="dseries class">
<link href="Time-Series.html#Time-Series" rel="prev" title="Time Series">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<a name="Dates"></a>
<div class="header">
<p>
Next: <a href="dseries-class.html#dseries-class" accesskey="n" rel="next">dseries class</a>, Up: <a href="Time-Series.html#Time-Series" accesskey="u" rel="up">Time Series</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Function-Index.html#Command-and-Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Dates-1"></a>
<h3 class="section">6.1 Dates</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#dates-in-a-mod-file" accesskey="1">dates in a mod file</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">• <a href="#dates-class" accesskey="2">dates class</a>:</td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr>
<a name="dates-in-a-mod-file"></a>
<div class="header">
<p>
Next: <a href="#dates-class" accesskey="n" rel="next">dates class</a>, Up: <a href="#Dates" accesskey="u" rel="up">Dates</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Function-Index.html#Command-and-Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="dates-in-a-mod-file-1"></a>
<h4 class="subsection">6.1.1 dates in a mod file</h4>
<p>Dynare understands dates in a mod file. Users can declare annual,
quarterly, monthly or weekly dates using the following syntax:
</p>
<div class="example">
<pre class="example">1990Y
1990Q3
1990M11
1990W49
</pre></div>
<p>Behind the scene, Dynare’s preprocessor translates these expressions
into instantiations of the Matlab/Octave’s class <code>dates </code> described
below. Basic operations can be performed on dates:
</p><dl compact="compact">
<dt><strong>plus binary operator (<code>+</code>)</strong></dt>
<dd>
<p>An integer scalar, interpreted as a number of periods, can be added to a date. For instance, if <code>a = 1950Q1</code> then
<code>b = 1951Q2</code> and <code>b = a + 5</code> are identical.
</p>
</dd>
<dt><strong>plus unary operator (<code>+</code>)</strong></dt>
<dd>
<p>Increments a date by one period. <code>+1950Q1</code> is identical to <code>1950Q2</code>, <code>++++1950Q1</code> is identical to <code>1951Q1</code>.
</p>
</dd>
<dt><strong>minus binary operator (<code>-</code>)</strong></dt>
<dd>
<p>Has two functions: difference and subtraction. If the second argument
is a date, calculates the difference between the first date and the
second date (<i>e.g.</i> <code>1951Q2-1950Q1</code> is equal to <code>5</code>). If
the second argument is an integer <code>X</code>, subtracts <code>X</code> periods
from the date (<i>e.g.</i> <code>1951Q2-2</code> is equal to <code>1950Q4</code>).
</p>
</dd>
<dt><strong>minus unary operator (<code>-</code>)</strong></dt>
<dd>
<p>Subtracts one period to a date. <code>-1950Q1</code> is identical to <code>1949Q4</code>. The unary minus operator is the reciprocal of the unary plus operator, <code>+-1950Q1</code> is identical to <code>1950Q1</code>.
</p>
</dd>
<dt><strong>colon operator (<code>:</code>)</strong></dt>
<dd>
<p>Can be used to create a range of dates. For instance, <code>r = 1950Q1:1951Q1</code> creates a <code>dates </code> object with five elements: <code>1950Q1</code>, <code>1950Q2</code>, <code>1950Q3</code>, <code>1950Q4</code> and <code>1951Q1</code>. By default the increment between each element is one period. This default can be changed using, for instance, the following instruction: <code>1950Q1:2:1951Q1</code> which will instantiate a <code>dates </code> object with three elements: <code>1950Q1</code>, <code>1950Q3</code> and <code>1951Q1</code>.
</p>
</dd>
<dt><strong>horzcat operator (<code>[,]</code>)</strong></dt>
<dd>
<p>Concatenates <code>dates </code> objects without removing repetitions. For instance <code>[1950Q1, 1950Q2]</code> is a a <code>dates </code> object with two elements (<code>1950Q1</code> and <code>1950Q2</code>).
</p>
</dd>
<dt><strong>vertcat operator (<code>[;]</code>)</strong></dt>
<dd>
<p>Same as <code>horzcat</code> operator.
</p>
</dd>
<dt><strong>eq operator (equal, <code>==</code>)</strong></dt>
<dd>
<p>Tests if two <code>dates </code> objects are equal. <code>+1950Q1==1950Q2</code> returns <code>1</code>, <code>1950Q1==1950Q2</code> returns <code>0</code>. If the compared objects have both <code>n>1</code> elements, the <code>eq</code> operator returns a column vector, <code>n</code> by <code>1</code>, of zeros and ones.
</p>
</dd>
<dt><strong>ne operator (not equal, <code>~=</code>)</strong></dt>
<dd>
<p>Tests if two <code>dates </code> objects are not equal. <code>+1950Q1~=1950Q2</code>
returns <code>0</code> while <code>1950Q1~=1950Q2</code> returns <code>1</code>. If the
compared objects both have <code>n>1</code> elements, the <code>ne</code> operator
returns an <code>n</code> by <code>1</code> column vector of zeros and ones.
</p>
</dd>
<dt><strong>lt operator (less than, <code><</code>)</strong></dt>
<dd>
<p>Tests if a <code>dates </code> object preceeds another <code>dates </code> object. For instance, <code>1950Q1<1950Q3</code> returns <code>1</code>. If the compared objects have both <code>n>1</code> elements, the <code>lt</code> operator returns a column vector, <code>n</code> by <code>1</code>, of zeros and ones.
</p>
</dd>
<dt><strong>gt operator (greater than, <code>></code>)</strong></dt>
<dd>
<p>Tests if a <code>dates </code> object follows another <code>dates </code> object. For instance, <code>1950Q1>1950Q3</code> returns <code>0</code>. If the compared objects have both <code>n>1</code> elements, the <code>gt</code> operator returns a column vector, <code>n</code> by <code>1</code>, of zeros and ones.
</p>
</dd>
<dt><strong>le operator (less or equal, <code><=</code>)</strong></dt>
<dd>
<p>Tests if a <code>dates </code> object preceeds another <code>dates </code> object or is equal to this object. For instance, <code>1950Q1<=1950Q3</code> returns <code>1</code>. If the compared objects have both <code>n>1</code> elements, the <code>le</code> operator returns a column vector, <code>n</code> by <code>1</code>, of zeros and ones.
</p>
</dd>
<dt><strong>ge operator (greater or equal, <code>>=</code>)</strong></dt>
<dd>
<p>Tests if a <code>dates </code> object follows another <code>dates </code> object or is equal to this object. For instance, <code>1950Q1>=1950Q3</code> returns <code>0</code>. If the compared objects have both <code>n>1</code> elements, the <code>ge</code> operator returns a column vector, <code>n</code> by <code>1</code>, of zeros and ones.
</p>
</dd>
</dl>
<p>One can select an element, or some elements, in a <code>dates </code> object as he would extract some elements from a vector in Matlab/Octave. Let <code>a = 1950Q1:1951Q1</code> be a <code>dates </code> object, then <code>a(1)==1950Q1</code> returns <code>1</code>, <code>a(end)==1951Q1</code> returns <code>1</code> and <code>a(end-1:end)</code> selects the two last elements of <code>a</code> (by instantiating the <code>dates </code> object <code>[1950Q4, 1951Q1]</code>).
</p>
<p><em>Remark</em>
Dynare substitutes any occurrence of dates in the mod file into an instantiation of the <code>dates </code> class regardless of the context. For instance, <code>d = 1950Q1;</code> will be translated as <code>d = dates('1950Q1');</code>. 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:
</p>
<div class="example">
<pre class="example">disp('Initial period is 1950Q1');
</pre></div>
<p>Dynare will translate this as:
</p>
<div class="example">
<pre class="example">disp('Initial period is dates('1950Q1')');
</pre></div>
<p>which will lead to a crash because this expression is illegal in Matlab. For this situation, Dynare provides the <code>$</code> escape parameter. The following expression:
</p>
<div class="example">
<pre class="example">disp('Initial period is $1950Q1');
</pre></div>
<p>will be translated as:
</p>
<div class="example">
<pre class="example">disp('Initial period is 1950Q1');
</pre></div>
<p>in the generated MATLAB script.
</p>
<hr>
<a name="dates-class"></a>
<div class="header">
<p>
Previous: <a href="#dates-in-a-mod-file" accesskey="p" rel="prev">dates in a mod file</a>, Up: <a href="#Dates" accesskey="u" rel="up">Dates</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Function-Index.html#Command-and-Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="dates-class-1"></a>
<h4 class="subsection">6.1.2 dates class</h4>
<p>The <code>dates </code> class has three members:
</p><dl compact="compact">
<dd><a name="dates-class-members"></a>
</dd>
<dt><code>freq</code></dt>
<dd><p>an integer equal to 1, 4, 12 or 52 (resp. for annual, quarterly, monthly
or weekly dates).
</p>
</dd>
<dt><code>ndat</code></dt>
<dd><p>an integer scalar, the number of declared dates in the object.
</p>
</dd>
<dt><code>time</code></dt>
<dd><p>a <code>ndat</code>*2 array of integers, the years are stored in the first
column, the subperiods (1 for annual dates, 1-4 for quarterly dates, 1-12
for monthly dates and 1-52 for weekly dates) are stored in the second
column.
</p>
</dd>
</dl>
<p>Each member is private, one can display the content of a member but cannot change its value:
</p>
<div class="example">
<pre class="example">>> d = dates('2009Q2');
>> d.time
ans =
2009 2
>>
</pre></div>
<p>Note that it is not possible to mix frequencies in a <code>dates </code> object: all the elements must have common frequency. The <code>dates </code> class has five constructors:
</p>
<br>
<dl>
<dt><a name="index-_0028_0029"></a>dates: <em>dates</em> <strong>()</strong></dt>
<dt><a name="index-_0028FREQ_0029"></a>dates: <em>dates</em> <strong>(<code>FREQ</code>)</strong></dt>
<dd>
<p>Returns an empty <code>dates </code> object with a given frequency (if the constructor is called with one input argument). <code>FREQ</code> is a character equal to ’Y’ or ’A’ for annual dates, ’Q’ for quarterly dates, ’M’ for monthly dates or ’W’ for weekly dates. Note that <code>FREQ</code> is not case sensitive, so that, for instance, ’q’ is also allowed for quarterly dates. The frequency can also be set with an integer scalar equal to 1 (annual), 4 (quarterly), 12 (monthly) or 52 (weekly). The instantiation of empty objects can be used to rename the <code>dates </code> class. For instance, if one only works with quarterly dates, he can create <code>qq</code> as:
</p>
<div class="example">
<pre class="example">qq = dates('Q')
</pre></div>
<p>and a <code>dates </code> object holding the date <code>2009Q2</code>:
</p>
<div class="example">
<pre class="example">d0 = qq(2009,2);
</pre></div>
<p>which is much simpler if <code>dates </code> objects have to be defined programmatically.
</p>
</dd></dl>
<br>
<dl>
<dt><a name="index-_0028STRING_0029"></a>dates: <em>dates</em> <strong>(<code>STRING</code>)</strong></dt>
<dt><a name="index-_0028STRING_002c"></a>dates: <em>dates</em> <strong>(<code>STRING</code>,</strong> <em><code>STRING</code>, ...)</em></dt>
<dd>
<p>Returns a <code>dates </code> object that represents a date as given by the string <code>STRING</code>. This string has to be interpretable as a date (only strings of the following forms are admitted: <code>'1990Y'</code>, <code>'1990A'</code>, <code>'1990Q1'</code>, <code>'1990M2'</code>, <code>'1990W5'</code>), the routine <code>isdate</code> can be used to test if a string is interpretable as a date. If more than one argument is provided, they should all be dates represented as strings, the resulting <code>dates </code> object contains as many elements as arguments to the constructor.
</p>
</dd></dl>
<br>
<dl>
<dt><a name="index-_0028DATES_0029"></a>dates: <em>dates</em> <strong>(<code>DATES</code>)</strong></dt>
<dt><a name="index-_0028DATES_002c"></a>dates: <em>dates</em> <strong>(<code>DATES</code>,</strong> <em><code>DATES</code>, ...)</em></dt>
<dd>
<p>Returns a copy of the <code>dates </code> object <code>DATES</code> passed as input arguments. If more than one argument is provided, they should all be <code>dates </code> objects. The number of elements in the instantiated <code>dates </code> object is equal to the sum of the elements in the <code>dates </code> passed as arguments to the constructor.
</p>
</dd></dl>
<br>
<dl>
<dt><a name="index-_0028FREQ_002c"></a>dates: <em>dates</em> <strong>(<code>FREQ</code>,</strong> <em><code>YEAR</code>, <code>SUBPERIOD</code>)</em></dt>
<dd>
<p>where <code>FREQ</code> is a single character (’Y’, ’A’, ’Q’, ’M’, ’W’) or integer (1, 4, 12 or 52) specifying the frequency, <code>YEAR</code> and <code>SUBPERIOD</code> are <code>n*1</code> vectors of integers. Returns a <code>dates </code> object with <code>n</code> elements. If <code>FREQ</code> is equal to <code>'Y', 'A'</code> or <code>1</code>, the third argument is not needed (because <code>SUBPERIOD</code> is necessarily a vector of ones in this case).
</p>
</dd></dl>
<br>
<p><em>Examples</em>
</p><div class="example">
<pre class="example">do1 = dates('1950Q1');
do2 = dates('1950Q2','1950Q3');
do3 = dates(do1,do2);
do4 = dates('Q',1950, 1);
</pre></div>
<br>
<p>A list of the available methods, by alphabetical order, is given below. Note that the Matlab/Octave classes do not allow in place modifications: when a method is applied to an object a new object is instantiated. For instance, to apply the method <code>multiplybytwo</code> to an object <code>X</code> we write:
</p>
<div class="example">
<pre class="example">Y = X.multiplybytwo()
</pre></div>
<p>or equivalently:
</p>
<div class="example">
<pre class="example">Y = multiplybytwo(X)
</pre></div>
<p>the object <code>X</code> is left unchanged, and the object <code>Y</code> is a modified copy of <code>X</code>.
</p>
<br>
<dl>
<dt><a name="index-append"></a>dates: <em><var>C</var> =</em> <strong>append</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Appends <code>dates </code> object <var>B</var>, or a string that can be interpreted as a date, to the <code>dates </code> object <var>A</var>. If <var>B</var> is a <code>dates </code> object it is assumed that it has no more than one element.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> D = dates('1950Q1','1950Q2');
>> d = dates('1950Q3');
>> E = D.append(d);
>> F = D.append('1950Q3')
>> isequal(E,F)
ans =
1
>> F
F = <dates: 1950Q1, 1950Q2, 1950Q3>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-colon"></a>dates: <em><var>C</var> =</em> <strong>colon</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dt><a name="index-colon-1"></a>dates: <em><var>C</var> =</em> <strong>colon</strong> <em>(<var>A</var>, <var>i</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave colon (:) operator. <var>A</var> and <var>B</var> are <code>dates </code> objects. The optional increment <var>i</var> is a scalar integer (default value is <code>i=1</code>). This method returns a <code>dates </code> object and can be used to create ranges of dates.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1');
>> B = dates('1951Q2');
>> C = A:B
C = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1>
>> D = A:2:B
D = <dates: 1950Q1, 1950Q3, 1951Q1>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-double"></a>dates: <em><var>B</var> =</em> <strong>double</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>double</code> function. <var>A</var> is a <code>dates </code> object. The method returns a floating point representation of a <code>dates </code> object, the integer and fractional parts respectively corresponding to the year and the subperiod. The fractional part is the subperiod number minus one divided by the frequency (<code>1</code>, <code>4</code>, <code>12</code> or <code>52</code>).
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> a = dates('1950Q1'):dates('1950Q4');
>> a.double()
ans =
1950.00
1950.25
1950.50
1950.75
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-eq"></a>dates: <em><var>C</var> =</em> <strong>eq</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>eq</code> (equal, <code>==</code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>). The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the dates <code>A(i)</code> and <code>B(i)</code> are the same.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A==B
ans =
1
0
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-ge"></a>dates: <em><var>C</var> =</em> <strong>ge</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>ge</code> (greater or equal, <code>>=</code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>). The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the date <code>A(i)</code> is posterior or equal to the date <code>B(i)</code>.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A>=B
ans =
1
1
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-gt"></a>dates: <em><var>C</var> =</em> <strong>gt</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>gt</code> (greater than, <code>></code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>). The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the date <code>A(i)</code> is posterior to the date <code>B(i)</code>.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A>B
ans =
0
1
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-horzcat"></a>dates: <em><var>D</var> =</em> <strong>horzcat</strong> <em>(<var>A</var>, <var>B</var>, <var>C</var>, ...)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>horzcat</code> operator. All the input arguments must be <code>dates </code> objects. The returned argument is a <code>dates </code> object gathering all the dates given in the input arguments (repetitions are not removed).
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1');
>> B = dates('1950Q2');
>> C = [A, B];
>> C
C = <dates: 1950Q1, 1950Q2>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-intersect"></a>dates: <em><var>C</var> =</em> <strong>intersect</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>intersect</code> function. All the input arguments must be <code>dates </code> objects. The returned argument is a <code>dates </code> object gathering all the common dates given in the input arguments. If <var>A</var> and <var>B</var> are disjoint <code>dates </code> objects, the function returns an empty <code>dates </code> object. Returned dates in <code>dates </code> object <var>C</var> are sorted by increasing order.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1'):dates('1951Q4');
>> B = dates('1951Q1'):dates('1951Q4');
>> C = intersect(A, B);
>> C
C = <dates: 1951Q1, 1951Q2, 1951Q3, 1951Q4>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-setdiff"></a>dates: <em><var>C</var> =</em> <strong>setdiff</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>setdiff</code> function. All the input arguments must be <code>dates </code> objects. The returned argument is a <code>dates </code> object all dates present in <var>A</var> but not in <var>B</var>. If <var>A</var> and <var>B</var> are disjoint <code>dates </code> objects, the function returns <var>A</var>. Returned dates in <code>dates </code> object <var>C</var> are sorted by increasing order.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1'):dates('1969Q4') ;
>> B = dates('1960Q1'):dates('1969Q4') ;
>> C = dates('1970Q1'):dates('1979Q4') ;
>> d1 = setdiff(d1,d2);
>> d2 = setdiff(d1,d3);
d1 = <dates: 1950Q1, 1950Q2, ..., 1959Q3, 1959Q4>
d2 = <dates: 1950Q1, 1950Q2, ..., 1969Q3, 1969Q4>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-isempty"></a>dates: <em><var>B</var> =</em> <strong>isempty</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave isempty function for <code>dates </code> object.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1'):dates('1951Q4');
>> A.isempty()
ans =
0
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-isequal"></a>dates: <em><var>C</var> =</em> <strong>isequal</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>isequal</code> function for <code>dates </code> objects.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1'):dates('1951Q4');
>> isequal(A,A)
ans =
1
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-le"></a>dates: <em><var>C</var> =</em> <strong>le</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>le</code> (less or equal, <code><=</code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>). The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the date <code>A(i)</code> is not posterior to the date <code>B(i)</code>.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A<=B
ans =
1
0
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-length"></a>dates: <em><var>B</var> =</em> <strong>length</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>length</code> function. Returns the number of dates in <code>dates </code> object <var>A</var> (<var>B</var> is a scalar integer).
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> A.length()
ans =
2
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-lt"></a>dates: <em><var>C</var> =</em> <strong>lt</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>lt</code> (less than, <code><</code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>). The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the date <code>A(i)</code> preceeds the date <code>B(i)</code>.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A<B
ans =
0
0
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-max-1"></a>dates: <em><var>D</var> =</em> <strong>max</strong> <em>(<var>A</var>, <var>B</var>, <var>C</var>, ...)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>max</code> function. All input arguments must be <code>dates </code> objects. The function returns a single element <code>dates </code> object containing the greatest date.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> max(A{:})
ans = <dates: 1953Q4>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-min-1"></a>dates: <em><var>D</var> =</em> <strong>min</strong> <em>(<var>A</var>, <var>B</var>, <var>C</var>, ...)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>min</code> function. All input arguments must be <code>dates </code> objects. The function returns a single element <code>dates </code> object containing the smallest date.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> min(A{:})
ans = <dates: 1794Q3>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-minus"></a>dates: <em><var>C</var> =</em> <strong>minus</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>minus</code> operator (<code>-</code>). If both input arguments are <code>dates </code> objects, then number of periods between <var>A</var> and <var>B</var> is returned (so that <code>A+C=B</code>). If <var>B</var> is a vector of integers, the <code>minus</code> operator shifts the <code>dates </code> object by <var>B</var> periods backward.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> d1 = dates('1950Q1','1950Q2','1960Q1');
>> d2 = dates('1950Q3','1950Q4','1960Q1');
>> ee = d2-d1
ee =
2
2
0
>> d1-(-ee)
ans = <dates: 1950Q3, 1950Q4, 1960Q1>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-ne"></a>dates: <em><var>C</var> =</em> <strong>ne</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>ne</code> (not equal, <code>~=</code>) operator. <code>dates </code> objects <var>A</var> and <var>B</var> must have the same number of elements (say, <code>n</code>) or one of the inputs must be a single element <code>dates </code> object. The returned argument is a <code>n</code> by <code>1</code> vector of zeros and ones. The i-th element of <var>C</var> is equal to <code>1</code> if and only if the dates <code>A(i)</code> and <code>B(i)</code> are different.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> A = dates('1950Q1','1951Q2');
>> B = dates('1950Q1','1950Q2');
>> A~=B
ans =
0
1
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-plus"></a>dates: <em><var>C</var> =</em> <strong>plus</strong> <em>(<var>A</var>, <var>B</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>plus</code> operator (<code>+</code>). If both input arguments are <code>dates </code> objects, then the method combines A and B without removing repetitions. If <var>B</var> is a vector of integers, the <code>plus</code> operator shifts the <code>dates </code> object by <var>B</var> periods forward.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> d1 = dates('1950Q1','1950Q2')+dates('1960Q1');
>> d2 = (dates('1950Q1','1950Q2')+2)+dates('1960Q1');
>> ee = d2-d1;
ee =
2
2
0
>> d1+ee
ans = <dates: 1950Q3, 1950Q4, 1960Q1>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-pop"></a>dates: <em><var>C</var> =</em> <strong>pop</strong> <em>(<var>A</var>)</em></dt>
<dt><a name="index-pop-1"></a>dates: <em><var>C</var> =</em> <strong>pop</strong> <em>(<var>A</var>,<var>B</var>)</em></dt>
<dd>
<p>Pop method for <code>dates </code> class. If only one input is provided, the method removes the last element of a <code>dates </code> object. If a second input argument is provided, a scalar integer between <code>1</code> and <code>A.length()</code>, the method removes element number <var>B</var> from <code>dates </code> object <var>A</var>.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> d1 = dates('1950Q1','1950Q2');
>> d1.pop()
ans = <dates: 1950Q1>
>> d1.pop(1)
ans = <dates: 1950Q2>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-sort"></a>dates: <em><var>B</var> =</em> <strong>sort</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Sort method for <code>dates </code> objects. Returns a <code>dates </code> object with elements sorted by increasing order.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> dd = dates('1945Q3','1938Q4','1789Q3');
>> dd.sort()
ans = <dates: 1789Q3, 1938Q4, 1945Q3>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-uminus"></a>dates: <em><var>B</var> =</em> <strong>uminus</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave unary minus operator. Returns a <code>dates </code> object with elements shifted one period backward.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> dd = dates('1945Q3','1938Q4','1973Q1');
>> -dd
ans = <dates: 1945Q2, 1938Q3, 1972Q4>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-union"></a>dates: <em><var>D</var> =</em> <strong>union</strong> <em>(<var>A</var>, <var>B</var>, <var>C</var>, ...)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>union</code> function. Returns a <code>dates </code> object with elements sorted by increasing order (repetitions are removed, to keep the repetitions use the <code>horzcat</code> or <code>plus</code> operators).
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> d1 = dates('1945Q3','1973Q1','1938Q4');
>> d2 = dates('1973Q1','1976Q1');
>> union(d1,d2)
ans = <dates: 1938Q4, 1945Q3, 1973Q1, 1976Q1>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-unique"></a>dates: <em><var>B</var> =</em> <strong>unique</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave <code>unique</code> function. Returns a <code>dates </code> object with repetitions removed (only the last occurence of a date is kept).
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> d1 = dates('1945Q3','1973Q1','1945Q3');
>> d1.unique()
ans = <dates: 1973Q1, 1945Q3>
</pre></div>
</dd></dl>
<br>
<dl>
<dt><a name="index-uplus"></a>dates: <em><var>B</var> =</em> <strong>uplus</strong> <em>(<var>A</var>)</em></dt>
<dd>
<p>Overloads the Matlab/Octave unary plus operator. Returns a <code>dates </code> object with elements shifted one period ahead.
</p>
<p><em>Example</em>
</p><div class="example">
<pre class="example">>> dd = dates('1945Q3','1938Q4','1973Q1');
>> +dd
ans = <dates: 1945Q4, 1939Q1, 1973Q2>
</pre></div>
</dd></dl>
<hr>
<div class="header">
<p>
Previous: <a href="#dates-in-a-mod-file" accesskey="p" rel="prev">dates in a mod file</a>, Up: <a href="#Dates" accesskey="u" rel="up">Dates</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Function-Index.html#Command-and-Function-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|