display.m 4.2 KB
Newer Older
1 2 3 4
function display(o)

% Overloads display method.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
5
% INPUTS
6 7
% - o  [dseries]   Object to be displayed.
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
8
% OUTPUTS
9 10
% None
%
Stéphane Adjemian's avatar
Stéphane Adjemian committed
11
% REMARKS
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
% Contray to the disp method, the whole dseries object is not displayed if the number of
% observations is greater than 40 and if the number of variables is greater than 10.

% Copyright (C) 2011-2017 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
31 32

vspace = ' ';
33

34 35 36 37 38
if ~vobs(o)
    disp(vspace)
    disp([inputname(1) ' is an empty dseries object.'])
    return
end
39

40 41
TABLE = ' ';

42 43 44 45 46
if vobs(o)<=10
    if nobs(o)<=40
        separator = repmat(' | ', nobs(o)+1,1);
        for t=1:nobs(o)
            TABLE = char(TABLE, date2string(o.dates(t)));
47
        end
48
        for i = 1:vobs(o)
49
            TABLE = horzcat(TABLE,separator);
50 51 52
            tmp = o.name{i};
            for t=1:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
53 54 55 56 57 58 59
            end
            TABLE = horzcat(TABLE, tmp);
        end
    else
        n = 10;
        separator = repmat(' | ',2*n+3,1);
        for t=1:n
60
            TABLE = char(TABLE, date2string(o.dates(t)));
61 62
        end
        TABLE = char(TABLE,vspace);
63 64
        for t = nobs(o)-n:nobs(o)
            TABLE = char(TABLE, date2string(o.dates(t)));
65
        end
66
        for i=1:vobs(o)
67
            TABLE = horzcat(TABLE,separator);
68
            tmp = o.name{i};
69
            for t=1:10
70
                tmp = char(tmp,num2str(o.data(t,i)));
71 72
            end
            tmp = char(tmp,vspace);
73 74
            for t=nobs(o)-10:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
75 76 77 78 79 80
            end
            TABLE = horzcat(TABLE, tmp);
        end
    end
else
    m = 4;
81 82 83 84
    if nobs(o)<=40
        separator = repmat(' | ', nobs(o)+1,1);
        for t=1:nobs(o)
            TABLE = char(TABLE, date2string(o.dates(t)));
85 86 87
        end
        for i = 1:m
            TABLE = horzcat(TABLE,separator);
88 89 90
            tmp = o.name{i};
            for t=1:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
91 92 93
            end
            TABLE = horzcat(TABLE, tmp);
        end
94 95
        TABLE = horzcat(TABLE, separator, repmat(' ... ', nobs(o)+1,1));
        for i = vobs(o)-m+1:vobs(o)
96
            TABLE = horzcat(TABLE,separator);
97 98 99
            tmp = o.name{i};
            for t=1:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
100 101 102 103 104 105 106
            end
            TABLE = horzcat(TABLE, tmp);
        end
    else
        n = 10;
        separator = repmat(' | ',2*n+3,1);
        for t=1:n
107
            TABLE = char(TABLE, date2string(o.dates(t)));
108 109
        end
        TABLE = char(TABLE,vspace);
110 111
        for t = nobs(o)-n:nobs(o)
            TABLE = char(TABLE, date2string(o.dates(t)));
112 113 114
        end
        for i=1:m
            TABLE = horzcat(TABLE,separator);
115
            tmp = o.name{i};
116
            for t=1:10
117
                tmp = char(tmp,num2str(o.data(t,i)));
118 119
            end
            tmp = char(tmp,vspace);
120 121
            for t=nobs(o)-10:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
122 123 124 125
            end
            TABLE = horzcat(TABLE, tmp);
        end
        TABLE = horzcat(TABLE, separator, repmat(' ... ', 2*n+3,1));
126
        for i=vobs(o)-m+1:vobs(o)
127
            TABLE = horzcat(TABLE,separator);
128
            tmp = o.name{i};
129
            for t=1:10
130
                tmp = char(tmp,num2str(o.data(t,i)));
131 132
            end
            tmp = char(tmp,vspace);
133 134
            for t=nobs(o)-10:nobs(o)
                tmp = char(tmp,num2str(o.data(t,i)));
135 136 137 138 139 140 141 142 143 144 145 146
            end
            TABLE = horzcat(TABLE, tmp);
        end
    end
end
disp(vspace)
disp([inputname(1) ' is a dseries object:'])
disp(vspace);
if ~isempty(strtrim(TABLE))
    disp(TABLE);
    disp(vspace);
end