Writing data from Julia to an Excel Spreadsheet

All of y, a and b are 10 element vectors, so you are picking 3 elements (element i from y, a, and b) respectively and try to store them in the first row of out, which has length 12.

It looks to me like you were intending to create a 10x10 matrix y from which you then want to select a 10-element vector to concatenate with elements a and b? That would be rand(10, 10) rather than rand(1:10, 10) - if you pass an iterable (like the range 1:10 as the first argument to rand, you will get a random draw from that iterable, compare:

julia> rand(1:3, 3)
3-element Vector{Int64}:
 2
 2
 1

julia> rand(3, 3)
3×3 Matrix{Float64}:
 0.196941  0.563995  0.406779
 0.583269  0.523321  0.252729
 0.70422   0.598516  0.239555
1 Like