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