Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/fn_imcerrgraph_scl.m

raw
1 function scaleout = fn_imcerrgraph_scl(imf,firstl,firsth,nvar,imstp,scaleout,xlab,ylab,indxGimfml,xTick)
2 % scaleout = fn_imcerrgraph(imf,firstl,firsth,nvar,imstp,xlab,ylab,indxGimfml,xTick)
3 % imcerrgraph: impulse, c (column: shock 1 to N), 1 error band, graph
4 %
5 % imf: imstp-by-nvar^2 matrix of impulse responses. Column (responses to 1st shock, responses to 2nd shock
6 % etc), Row (impusle steps),
7 % firstl: lower band
8 % highth: high band
9 % nvar: number of variables
10 % imstp: number of steps of impulse responses
11 % xlab,ylab: labels
12 % indxGimfml: 1, graph; 0, no graph
13 % xTick: optional. Eg: [12 24 36].
14 %---------------
15 % scaleout: column 1 represents maximums; column 2 minimums. Rows: nvar variables.
16 %
17 % See fn_imcgraph, fn_imc2errgraph, imrerrgraph
18 %
19 % Copyright (C) 1997-2012 Tao Zha
20 %
21 % This free software: you can redistribute it and/or modify
22 % it under the terms of the GNU General Public License as published by
23 % the Free Software Foundation, either version 3 of the License, or
24 % (at your option) any later version.
25 %
26 % It is distributed in the hope that it will be useful,
27 % but WITHOUT ANY WARRANTY; without even the implied warranty of
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 % GNU General Public License for more details.
30 %
31 % If you did not received a copy of the GNU General Public License
32 % with this software, see <http://www.gnu.org/licenses/>.
33 %
34
35
36 if nargin < 10, xTick = []; end
37
38 t = 1:imstp;
39 if isempty(scaleout)
40 temp1=zeros(nvar,1);
41 temp2=zeros(nvar,1);
42 maxval=zeros(nvar,1);
43 minval=zeros(nvar,1);
44 for i = 1:nvar
45 for j = 1:nvar
46 temp1(j)=max(firsth(:,(j-1)*nvar+i));
47 temp2(j)=min(firstl(:,(j-1)*nvar+i));
48 end
49 maxval(i)=max(temp1);
50 minval(i)=min(temp2);
51 end
52 scaleout = [maxval(:) minval(:)];
53 else
54 maxval = scaleout(:,1);
55 minval = scaleout(:,2);
56 end
57
58
59 %--------------
60 % Column j: Shock 1 to N; Row i: Responses to
61 %-------------
62 if indxGimfml
63 %figure
64 rowlabel = 1;
65 for i = 1:nvar
66 columnlabel = 1;
67
68 if minval(i)<0
69 if maxval(i)<=0
70 yt=[minval(i) 0];
71 else
72 yt=[minval(i) 0 maxval(i)];
73 end
74 else % (minval(i) >=0)
75 if maxval(i) > 0
76 yt=[0 maxval(i)];
77 else % (identically zero responses)
78 yt=[-1 0 1];
79 end
80 end
81
82 scale=[1 imstp minval(i) maxval(i)];
83 for j = 1:nvar
84 k1=(i-1)*nvar+j;
85 k2=(j-1)*nvar+i;
86 subplot(nvar,nvar,k1)
87 plot(t,imf(:,k2),t,[firstl(:,k2) firsth(:,k2)],'--',...
88 t,zeros(length(imf(:,k2)),1),'-');
89
90 set(gca,'XTick',xTick)
91 set(gca,'YTick',yt)
92 grid
93
94 axis(scale); % put limits on both axes.
95 %set(gca,'YLim',[minval(i) maxval(i)])
96 if 1 % no numbers on axes
97 set(gca,'XTickLabel',' ');
98 set(gca,'YTickLabel',' ');
99 else % put numbers on both axes
100 if i<nvar
101 set(gca,'XTickLabelMode','manual','XTickLabel',[])
102 end
103 if j>1
104 set(gca,'YTickLabel',' ');
105 end
106 end
107
108 if rowlabel == 1
109 %title(['x' num2str(j)])
110 %title(eval(['x' num2str(j)]))
111 title(char(xlab(j)))
112 end
113 if columnlabel == 1
114 %ylabel(['x' num2str(i)])
115 %ylabel(eval(['x' num2str(i)]))
116 ylabel(char(ylab(i)))
117 end
118 columnlabel = 0;
119 end
120 rowlabel = 0;
121 end
122 end