1function scaleout = fn_multigraph1(imf1,nrow,ncol,xlab,ylab,XTick,YTickIndx,scaleIndx)
2%Plot only one set of impulse responses in one graph.  See fn_multigraph2.m.
3%imf1 -- each has 3 dimensions.  Row: horizon; column: 'nrow' variables; 3rd dim: 'ncol' situations such as regimes 1 and 2.
4%   imf: row: "nstp" time horizon (in the graphics), column: "nrow "variables (row in
5%             the graphics), 3rd D: across "ncol" different situations (column in
6%             the graphics)
7%   nrow:  # of rows for the graphics
8%   ncol:  # of columns for the graphics
9%   YTickIndx:  1: enable YTick; 0: disable
10%   scaleIndx:  1: enable scale along Y-axis; 0: disable
11%
12%  See imrgraph, imcerrgraph, imrerrgraph
13%
14% Copyright (C) 1997-2012 Tao Zha
15%
16% This free software: you can redistribute it and/or modify
17% it under the terms of the GNU General Public License as published by
18% the Free Software Foundation, either version 3 of the License, or
19% (at your option) any later version.
20%
21% It is distributed in the hope that it will be useful,
22% but WITHOUT ANY WARRANTY; without even the implied warranty of
23% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24% GNU General Public License for more details.
25%
26% If you did not received a copy of the GNU General Public License
27% with this software, see <http://www.gnu.org/licenses/>.
28%
29
30nstp = size(imf1,1);
31t = 1:nstp;
32nrow;
33ncol;
34
35temp1=zeros(ncol,1);
36temp2=zeros(ncol,1);
37maxval=zeros(nrow,1);
38minval=zeros(nrow,1);
39for i = 1:nrow
40   for j = 1:ncol
41      %jnk1=max(firsth(:,i,j));
42      %jnk2=max(firstl(:,i,j));
43      %jnk3=max(firsth1(:,i,j));
44      %jnk4=max(imf2(:,i,j));
45      jnk5=max(imf1(:,i,j));
46
47      temp1(j)=max([jnk5]);
48      %
49      %jnk1=min(firstl(:,i,j));
50      %jnk2=min(firsth(:,i,j));
51      %jnk3=min(firstl1(:,i,j));
52      %jnk4=min(imf2(:,i,j));
53      jnk5=min(imf1(:,i,j));
54
55      temp2(j)=min([jnk5]);
56	end
57   maxval(i)=max(temp1);
58   minval(i)=min(temp2);
59end
60
61scaleout = [maxval(:) minval(:)];
62
63%--------------
64%  Column j: situation 1 to N; Row i: variables (ie responses to)
65%-------------
66%figure
67rowlabel = 1;
68for i = 1:nrow      % column: from top to bottom
69   columnlabel = 1;
70
71   if minval(i)<0
72      if maxval(i)<=0
73         yt=[minval(i) 0];
74		else
75         yt=[minval(i) 0 maxval(i)];
76		end
77   else % (minval(i) >=0)
78      if maxval(i) > 0
79         yt=[0 maxval(i)];
80		else % (identically zero responses)
81			yt=[-1 0 1];
82		end
83	end
84
85
86   scale=[1 nstp minval(i) maxval(i)];
87   for j = 1:ncol        % row: from left to right
88      k1=(i-1)*ncol+j;
89      subplot(nrow,ncol,k1)
90      plot(t,imf1(:,i,j)) %,t,imf2(:,i,j),'--')
91                %t,[firstl(:,i,j) firsth(:,i,j)],':');
92      grid;
93      if scaleIndx
94         axis(scale);
95      end
96      %set(gca,'YLim',[minval(i) maxval(i)])
97      %
98		set(gca,'XTick',XTick)
99      if YTickIndx
100         set(gca,'YTick',yt)
101      end
102
103      if i<nrow
104			set(gca,'XTickLabelMode','manual','XTickLabel',[])
105		end
106      %set(gca,'XTickLabel',' ');
107      if j>1
108         set(gca,'YTickLabel',' ');
109      end
110      if rowlabel == 1
111         %title(['x' num2str(j)])
112         %title(eval(['x' num2str(j)]))
113         title(char(xlab(j)))
114      end
115      if columnlabel == 1
116         %ylabel(['x' num2str(i)])
117         %ylabel(eval(['x' num2str(i)]))
118         ylabel(char(ylab(i)))
119      end
120      if i==nrow
121         xlabel('Quarters')
122      end
123      columnlabel = 0;
124   end
125   rowlabel = 0;
126end
127