 # Parallel for loops

Hello I am trying to do the following routine but there is a mistake in the following part:

wage_matrix_m[i,1]=7 ;
wage_matrix_f[i,1]=7 ;
wage_matrix_m[i,2]=7 ;
wage_matrix_f[i,2]=7 ;

I have read the manual and maybe I misunderstood the instructions, any guide about the correct way to code this will be highly appreciated.

Thank you.

``````/* Initialization of Variables */
wage_matrix_m = zeros(sample_size,column_matrices_max) ;
wage_matrix_f = zeros(sample_size,column_matrices_max) ;
counter_kids = seqa(1,1,column_matrices_max) ;
comp_kids_matrix = zeros(sample_size,column_matrices_max) ;
duration_matrix = zeros(sample_size,column_matrices_max) ;
HHprod_matrix = zeros(sample_size,column_matrices_max) ;
value_matrix = zeros(sample_size,column_matrices_max) ;
state_matrix = zeros(sample_size,column_matrices_max) ;
ii_total = ones(sample_size,1).*2 ; /* spell_counter */
ii_total_k = ones(sample_size,1) ; /* kids spell_counter */
ii_labor_m = ones(sample_size,1) ; /* firing shock males*/
ii_labor_f = ones(sample_size,1) ; /* firing shock females*/

/* Simulation */
threadFor i (1,sample_size,1) ;//i;

ind_kids = 0; /*indicator if the kids shock had happened*/
next_state = 1; /*formerly zeros(sample_size,column_matrices_max)*/
labor_time = 0;
n_sta = 0;
state = 0;
ii_wage_m = 1;
ii_wage_f = 1;

wage_matrix_m[i,1]=7 ;
wage_matrix_f[i,1]=7 ;
wage_matrix_m[i,2]=7 ;
wage_matrix_f[i,2]=7 ;
w_ind_m=minindc( miss(maxc( (w1_vector~wage_matrix_m[i,1]*ones(N_w1 ,1) )') , wage_matrix_m[i,1]) ) ;
w_ind_f=minindc( miss(maxc( (w2_vector~wage_matrix_f[i,1]*ones(N_w1 ,1) )') , wage_matrix_f[i,1]) ) ;

0

There can only be one slice assignment to a variable in the loop. You can change the four individual assignments to two, like this

``````threadfor i (1,sample_size,1) ;//i;

ind_kids = 0; /*indicator if the kids shock had happened*/
next_state = 1; /*formerly zeros(sample_size,column_matrices_max)*/
labor_time = 0;
n_sta = 0;
state = 0;
ii_wage_m = 1;
ii_wage_f = 1;

wage_matrix_m[i,1:2] = 7~7;
wage_matrix_f[i,1:2] = 7~7;

and the problem should be resolved. aptech
1,653

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.

### Try GAUSS for 14 days for FREE

See what GAUSS can do for your data