I want to save results of a simulation that outputs an array of variable length. Normally I would run the simulation, save it in an array, concatenate it with an array with previous results and then save the array which has all results by making a data frame and then using CSV.write. However since the arrays are of variable length hcat() won't work. Below a toy example of what I would like to do.
output = zeros(5)
number_simulations = 10
for i = 1:number_simulations
l = sample([4, 5, 6, 7])
print(l)
for j = 1:l
new_out = zeros(l)
hcat(output, new_out)
end
end
df = convert(DataFrame, output)
CSV.write("out.csv", df)
This returns error
DimensionMismatch("vectors must have same lengths").
Is there a simple workaround that would allow me to have a file with the results of each simulation in separate columns?