Bad gradient error by changing shock

Dear all,
I am working on IRF-matching technique. whenever, I change shock in my model like I add price shock instead of technology shock. I got error as "bad gradient’ and my estimation returns no results.

%set impulse to 1 percent of GDP
shock_vector=zeros(n_augmented_vars,1);
shock_pos=y_pos;
shock_vector(shock_pos)=1/Q(shock_pos,shock_pos); %set to 1 percent of G

if I add

%set impulse to 1 percent of GDP
shock_vector=zeros(n_augmented_vars,1);
shock_pos=pie_pos;
shock_vector(shock_pos)=1/Q(shock_pos,shock_pos); %set to 1 percent of G

I got error as ‘bad gradient’

can anyone help me where I am wrong
finaldata.xlsx (105.7 KB)
IRFNEW.mod (6.7 KB)
build_companionform.m (752 Bytes)
get_empirical_IRFs.m (6.3 KB)
IRF_matching_objective.m (1.4 KB)