Proper way to concatenate higher-dimensional arrays?

Sorry, my example is the same nested loop, just using a more compact syntax. Rewritten with your loop structure,

DatArr = [ElasticMatrix{Float64}(undef, 3, 0) for j = 1:Nj, k = 1:Nk]
for i in 1:5
	for j in 1:Nj
		for k in 1:Nk
			Nrand = rand(1:10)
			xyzVect = ElasticArray{Float64}(undef, 3, 0)
			for n in 1:Nrand
			   append!(xyzVect,rand(3))
			end
			append!(DatArr[j,k], xyzVect)
		end
	end    
end
1 Like

I thought I tried that exact thing!!

The only difference seems to be in the definition line DatArr = [ElasticMatrix....

Anyway, this seems to work, thank you!
I will analyze and see what it produces, I’m optimistic…

The other difference is here:

append!(DatArr[j,k,:,:], xyzVect)

to

append!(DatArr[j,k], xyzVect)
1 Like

Yes, stillyslalom, the method works.
Thanks for the help!

1 Like