I am trying to create a data structure that can hold vectors that have different lengths, and I don’t know how many vectors I will have to store. I have been struggling with coming up with a method that can accomplish this. I have developed the following code to accomplish this:
function TestFunction(PreVec) for i=1:5 Number = rand(1:10) NewVec = rand(1:10,Number,1 ) Combined = [PreVec, NewVec] PreVec = Combined println(size(Combined)) end end NumberInit = rand(1:10) PreVec = rand(1:10,NumberInit,1 ) TestFunction(PreVec)
The issue with the above method is that I want my code to generate an array that has a length equivalent to the number of vectors that have been stored in the array. What the code above produces however is a nested array so that it is always of size 2. How could I modify the code above or use a different method to avoid this issue that I have of the nested arrays?