I have 6 different scenarios, and under each scenario, there could be one to 100 models available for me to get the data. My goal is to store them in A as below (n is an unknown number between 1 and 100):

for i in 1:6 # Go through all of the scenarios
# go through the 100 models
A = []; # the step I need help.
n = 0;
for j = 1:100
if a model is available
n .+ 1
A[n] = Model n (35 grids, each with a size of 360 x 180);
end
end
# other calculations that requires A
end

Here is my question. Under each of the scenario, I would need to reset my A to empty values. How do I do that? In Matlab, I can just do the below: A = [];
Unfortunately, it does not work for Julia, as we know, Julia needs to know the exact size of the A, which is unknown in this example. How should I deal with this situation?

Actually, my model output is not a matrix with the size of 360x180. It is 35 matrices with the size of 360x180, like this: Model1[1] = grid1, Model1[2] = grid2, ..., Model1[35] = grid35.

In that case, how do I modify the below to fit my purpose? x = Matrix{Float64}[]

Using the above directly gives me the below error:

LoadError: MethodError: no method matching Matrix{Float64}(::Vector{Any})
Closest candidates are:
Array{T, N}(::AbstractArray{S, N}) where {T, N, S}

One would need to see exactly what is the type of grid.

But you can use x = [] and just add anything there, it is just that this is of type Any and may have some performance effect later (although all this is highly speculative with the information we have here).

You can use Vector{Vector{Any}} then for the container, but more for clarity than for anything, since you are already getting Any from the data you are fetching.

Technically, accessing the outer Vector{Vector{Any}} is not type-unstable, only accessing a position in one of the inner Vector is type-unstable. However, the type may have been deduced as Vector{Any} because some of the inner vectors are Vector{X} and other Vector{Y} (in this case the inner vectors themselves are of specific types and the outer vector must be Vector{Any}).