I'm running into the problem of accumulating an array with a for-loop (my array is called condition_list, and each row stores a unique configuration of parameters).
The code below is what I'm imagining for building this array:
param1_vals = [1.0f0 2.0f0 3.0f0]; # specific values here don't matter
param2_vals = [1.0f0 2.0f0 3.0f0]; # specific values here don't matter
param3_vals = [1.0f0 2.0f0 3.0f0]; # specific values here don't matter
condition_list = zeros(Float32, 1, 3) # initialize condition_list
for ii = 1:length(param1_vals)
for jj = 1:length(param2_vals)
for kk = 1:length(param3_vals)
row_to_stack = [param1_vals[ii], param2_vals[jj], param3_vals[kk])
condition_list = vcat(condition_list, row_to_stack)
end
end
end
condition_list = condition_list[2:end,:] # pop off that first row (leftover of the initialization)
So each row of the resulting condition_list should have a unique configuration of each of the values of param1_vals , param2_vals , and param3_vals.
The issue I'm running into is about scope of local variables -- I get a condition_list is not defined error at the inner most line of the loop, when using vcat. What's the most Julian way to approach this problem, if I can't use an array accumulation? Or perhaps there's some solution using push! or something?
Also, is there a way you can accumulate an array without doing the stupid 'pop off the first row 'thing I did at the end? Can you start with a zero-row, 3 column array and accumulate rows onto it?