
function [out,tmp]=getexpIRF(K1P_cP,A0,horizon,bb,minh,maxh,dt,L,sp,scale)
N=cols(A0);
 shock=zeros(1,N);
 shock(sp)=1;
 irfmp=irfsimx(K1P_cP',N,L,A0,shock,horizon+maxh,0);
 %size(irfmp)
 irfSR=irfmp(:,1:3)*bb(2:end);%+bb(1);
 if scale
 irfSR=irfSR./irfSR(1,1);
 end
 tmp=[irfSR];
    for h=1:maxh-1
        tmp=[tmp lagmatrix(irfSR,-h)]; %[irf irf(+1) irf(+2)....irf(horizon-1)] mean of cols gives response of yield
    end
    
    out=mean(tmp(1:horizon,minh:maxh),2)*dt;