Debian Codegraph @

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

raw
1 function scaleout = perr2graph(imf,firstl1,firsth1,...
2 firstl,firsth,nrow,ncol,nstp,xlab,ylab,XTick,YTickIndx,scaleIndx)
3 % scaleout = perr2graph(imf,firstl1,firsth1,...
4 % firstl,firsth,nrow,ncol,nstp,xlab,ylab,XTick,YTickIndx,scaleIndx)
5 %
6 % imf: nstp-by-nrow-by-ncol
7 % nrow: # of rows for the graphics (normally variables)
8 % ncol: # of columns for the graphics (normally situations such as shocks)
9 % firstl1: lower band, .68, nstp-by-nrow-by-ncol
10 % highth1: high band, .68, nstp-by-nrow-by-ncol
11 % firstl: lower band, .90, nstp-by-nrow-by-ncol
12 % highth: high band, .90, nstp-by-nrow-by-ncol
13 % YTickIndx: 1: enable YTick; 0: disable
14 % scaleIndx: 1: enable scale along Y-axis; 0: disable
15 % xlab,ylab: labels
16 %
17 % See imrgraph, imcerrgraph, 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 t = 1:nstp;
37 nrow
38 ncol
39
40 temp1=zeros(ncol,1);
41 temp2=zeros(ncol,1);
42 maxval=zeros(nrow,1);
43 minval=zeros(nrow,1);
44 for i = 1:nrow
45 for j = 1:ncol
46 jnk1=max(firsth(:,i,j));
47 jnk2=max(firstl(:,i,j));
48 jnk3=max(firsth1(:,i,j));
49 jnk4=max(firstl1(:,i,j));
50 jnk5=max(imf(:,i,j));
51
52 temp1(j)=max([jnk1 jnk2 jnk3 jnk4 jnk5]);
53 %
54 jnk1=min(firstl(:,i,j));
55 jnk2=min(firsth(:,i,j));
56 jnk3=min(firstl1(:,i,j));
57 jnk4=min(firsth1(:,i,j));
58 jnk5=min(imf(:,i,j));
59
60 temp2(j)=min([jnk1 jnk2 jnk3 jnk4 jnk5]);
61 end
62 maxval(i)=max(temp1);
63 minval(i)=min(temp2);
64 end
65
66 scaleout = [maxval(:) minval(:)];
67
68 %--------------
69 % Column j: Shock 1 to N; Row i: Responses to
70 %-------------
71 figure
72 rowlabel = 1;
73 for i = 1:nrow % column: from top to bottom
74 columnlabel = 1;
75
76 if minval(i)<0
77 if maxval(i)<=0
78 yt=[minval(i) 0];
79 else
80 yt=[minval(i) 0 maxval(i)];
81 end
82 else % (minval(i) >=0)
83 if maxval(i) > 0
84 yt=[0 maxval(i)];
85 else % (identically zero responses)
86 yt=[-1 0 1];
87 end
88 end
89
90
91 scale=[1 nstp minval(i) maxval(i)];
92 for j = 1:ncol % row: from left to right
93 k1=(i-1)*ncol+j;
94 subplot(nrow,ncol,k1)
95 plot(t,imf(:,i,j),t,[firstl1(:,i,j) firsth1(:,i,j)],'k--',...
96 t,[firstl(:,i,j) firsth(:,i,j)],'k-.',t,zeros(length(imf(:,i,j)),1),'k-');
97 grid;
98 if scaleIndx
99 axis(scale);
100 end
101 %set(gca,'YLim',[minval(i) maxval(i)])
102 %
103 set(gca,'XTick',XTick)
104 if YTickIndx
105 set(gca,'YTick',yt)
106 end
107
108 if i<nrow
109 set(gca,'XTickLabelMode','manual','XTickLabel',[])
110 end
111 %set(gca,'XTickLabel',' ');
112 if j>1
113 set(gca,'YTickLabel',' ');
114 end
115 if rowlabel == 1
116 %title(['x' num2str(j)])
117 %title(eval(['x' num2str(j)]))
118 title(char(xlab(j)))
119 end
120 if columnlabel == 1
121 %ylabel(['x' num2str(i)])
122 %ylabel(eval(['x' num2str(i)]))
123 ylabel(char(ylab(i)))
124 end
125 columnlabel = 0;
126 end
127 rowlabel = 0;
128 end