how can i create (generate) the Loop to Access Subfields:
Dears,
I need your help. hocan I access the subfields within eps_G, where eps_G is a structure.
whos myirfs1
Name Size Bytes Class Attributes
myirfs1 1×1 374094 struct
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% choose 1 or 2 below
shock_type = {‘eps_G’,’eps_nu’};
var_aux = {‘log_y’,’C’,’pi_ann’,’B_nominal’,’B’,’sp’,’i_ann’,’r_real_ann’,’P’};
var_aux2 = {‘log_y_eps_nu’,’C_eps_nu’,’pi_ann_eps_nu’,’B_nominal_eps_nu’,’B_eps_nu’,’sp_eps_nu’,’i_ann_eps_nu’,’r_real_ann_eps_nu’,’P_eps_nu’};
var_aux3 = {‘eps_G_log_y’,’eps_G_C’,’eps_G_pi_ann’,’eps_G_B_nominal’,’eps_G_B’,’eps_G_sp’,’eps_G_i_ann’,’eps_G_r_real_ann’,’eps_G_P’};
%Irfs of monetary and fiscal policy
irf_mon = struct();
irf_fisc = struct();
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% when i run the following code it is unrecognized. can you suggest me what to do?
for i = 1:numel(var_aux)
irf_mon.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
irf_fisc.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
end
Unrecognized field name "log_y_eps_G".Dears,
I need your help. hocan I access the subfields within eps_G, where eps_G is a structure.
whos myirfs1
Name Size Bytes Class Attributes
myirfs1 1×1 374094 struct
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% choose 1 or 2 below
shock_type = {‘eps_G’,’eps_nu’};
var_aux = {‘log_y’,’C’,’pi_ann’,’B_nominal’,’B’,’sp’,’i_ann’,’r_real_ann’,’P’};
var_aux2 = {‘log_y_eps_nu’,’C_eps_nu’,’pi_ann_eps_nu’,’B_nominal_eps_nu’,’B_eps_nu’,’sp_eps_nu’,’i_ann_eps_nu’,’r_real_ann_eps_nu’,’P_eps_nu’};
var_aux3 = {‘eps_G_log_y’,’eps_G_C’,’eps_G_pi_ann’,’eps_G_B_nominal’,’eps_G_B’,’eps_G_sp’,’eps_G_i_ann’,’eps_G_r_real_ann’,’eps_G_P’};
%Irfs of monetary and fiscal policy
irf_mon = struct();
irf_fisc = struct();
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% when i run the following code it is unrecognized. can you suggest me what to do?
for i = 1:numel(var_aux)
irf_mon.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
irf_fisc.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
end
Unrecognized field name "log_y_eps_G". Dears,
I need your help. hocan I access the subfields within eps_G, where eps_G is a structure.
whos myirfs1
Name Size Bytes Class Attributes
myirfs1 1×1 374094 struct
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% choose 1 or 2 below
shock_type = {‘eps_G’,’eps_nu’};
var_aux = {‘log_y’,’C’,’pi_ann’,’B_nominal’,’B’,’sp’,’i_ann’,’r_real_ann’,’P’};
var_aux2 = {‘log_y_eps_nu’,’C_eps_nu’,’pi_ann_eps_nu’,’B_nominal_eps_nu’,’B_eps_nu’,’sp_eps_nu’,’i_ann_eps_nu’,’r_real_ann_eps_nu’,’P_eps_nu’};
var_aux3 = {‘eps_G_log_y’,’eps_G_C’,’eps_G_pi_ann’,’eps_G_B_nominal’,’eps_G_B’,’eps_G_sp’,’eps_G_i_ann’,’eps_G_r_real_ann’,’eps_G_P’};
%Irfs of monetary and fiscal policy
irf_mon = struct();
irf_fisc = struct();
%% disp(fieldnames(myirfs1))
>> disp(fieldnames(myirfs1))
{‘eps_CP’}
{‘eps_G’ }
{‘eps_T’ }
{‘eps_a’ }
{‘eps_nu’}
{‘eps_z’ }
% when i run the following code it is unrecognized. can you suggest me what to do?
for i = 1:numel(var_aux)
irf_mon.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
irf_fisc.(var_aux{i}) = [0,myirfs1(1).(var_aux3{i})]’;
end
Unrecognized field name "log_y_eps_G". matlab coding ms dsge modelin MATLAB Answers — New Questions