Debian Codegraph @

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

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