irf_l=input('Choose IRFs length: ');
disp('LIST OF VARIABLES')
[num2str([1:neq]'),new_varnames]
nn=input('Give vector of variables # for IRF ==>');
kb=0;
if size(nn,2)<=4
    figure
    for jj=1:size(nn,2)
        subplot(2,2,jj)
        plot(IRF(nn(jj),block:block+irf_l),'-r')
         hold on
        plot(IRFRE(nn(jj),block:block+irf_l),'k-.','LineWidth',2)
        hold on
%         plot(UP_25(nn(jj),block:block+irf_l),'r--')
%         hold on
%         plot(LOW_25(nn(jj),block:block+irf_l),'r--')
        h=ciplot(LOW_25(nn(jj),block:block+irf_l),UP_25(nn(jj),block:block+irf_l),1:irf_l+1,'b');
        set(h,'FaceAlpha',.3)
       
        xlim([0 irf_l+1]);
        string=['IRF of ',new_varnames(nn(jj),:)];
        title(string);
    end
else
    for jj=1:fix(size(nn,2)/4+1)
        
        figure(jj)
        for kk=1:4
           
        subplot(2,2,kk)
        plot(IRF(nn(kk+kb),block:block+irf_l),'-r')
        hold on
%         plot(UP_25(nn(kk+kb),block:block+irf_l),'r--') 
%         hold on
%         plot(LOW_25(nn(kk+kb),block:block+irf_l),'r--')
%         hold on
        plot(IRFRE(nn(1),block:block+irf_l),'k-.','LineWidth',2)
      
        h=ciplot(LOW_25(nn(kk+kb),block:block+irf_l),UP_25(nn(kk+kb),block:block+irf_l),1:irf_l+1,'b');
        set(h,'FaceAlpha',.3)
        
        xlim([0 irf_l+1]);
        string=['IRF of ',new_varnames(nn(kk+kb),:)];
        title(string);
        if kb+kk+1>size(nn,2)
            break
        end
        end
        kb=kb+kk;
        if kb+1>size(nn,2)
            break
        end
    end
end


%PREPARE THE TABLE
clearvars xx
Var1=mean(var(TOT_IRF(:,block:block+irf_l,:),0,2),3);
Var2=mean(var(TOT_IRFRE(:,block:block+irf_l,:),0,2),3);
% Var3=mean(var(YRE(:,block:block+irf_l,:),0,2),3);
XX=Var1(nn);
XX2=Var2(nn);
% XX3=Var3(nn);

% XX=V_Y(nn);
% XX2=V_Y2(nn);
% XX3=V_RE(nn);
PF=NaN(size(nn,2),1);
PF(1,1)=sum(prfJ)/(S1*S2);
  


nomi=[];
for jj=1:size(nn,2)
    aa=new_varnames(nn(jj),:);
    nomi=[nomi ;{aa}];
end
% PF2=NaN(size(XX3));
% PF2(1)=PF;
% H=table(XX,XX2,XX3,PF,'RowNames',nomi,'VariableNames',{'Var_Shock' 'Var_No_Shock' 'Var_RE' 'PF'})
H=table(XX,XX2,PF,'RowNames',nomi,'VariableNames',{'Var_Learning' 'Var_RE' 'PF'})
string=[namemod,'_variances'];

for jj=1:size(XX,1)
    xx(jj,1)={XX(jj,1)};
end

to_save=[nomi xx];
string2=['Saving variances as ',string,'.'];
display(string2);
string2;
save(string,'to_save');


% XX={XX};
% to_save.nomi=nomi;
% to_save.XX=XX;%=[nomi cell2str(XX)];
% string2=['Saving variances as ',string,'.'];
% display(string2);
% string2;
% save(string,'to_save');