Does Julia have something equivalent to matlab's Cell Array?

I have 20 land/sea masks (gridded data at 360x180 degrees). I want to save them into a cell array called A. In Matlab I would do this:
A{1} = grid1;
A{2} = grid2;
ā€¦

How could I do the same thing in Julia, so that I could save the data into my hard disk?

Many thanks!

no idea what a cell array is, but it sounds like you just want to save 20 x (360*180) matrix to disk?

1 Like

In Julia you can for an array of whatever, even arrays (matrices):

julia> grid1 = rand(5,5)

5Ɨ5 Matrix{Float64}:
 0.467714  0.429285  0.116773  0.350455  0.909679
 0.229699  0.293745  0.227465  0.736049  0.179704
 0.48666   0.493857  0.506317  0.331685  0.743395
 0.869754  0.633566  0.916483  0.831438  0.274217
 0.455223  0.752233  0.269686  0.442151  0.651999

julia> grid2 = rand(5,5)
5Ɨ5 Matrix{Float64}:
 0.478697    0.176438  0.830284  0.56271    0.432144
 0.00510756  0.766706  0.921948  0.0810255  0.373836
 0.453284    0.608438  0.951807  0.83593    0.519139
 0.219918    0.265063  0.555579  0.84804    0.393806
 0.154247    0.50338   0.192671  0.042116   0.494513

julia> A = [grid1,grid2]
2-element Vector{Matrix{Float64}}:
 [0.46771415724714926 0.4292854363387988 ā€¦ 0.3504553296801125 0.9096786834636816; 0.22969946979881595 0.2937453236076222 ā€¦ 0.7360487498460107 0.17970412714281903; ā€¦ ; 0.8697537712407086 0.6335658434161404 ā€¦ 0.8314382719780808 0.27421748106887356; 0.45522271387465585 0.7522332919993941 ā€¦ 0.4421514101796373 0.6519989589354669]
 [0.47869695976448257 0.17643786983846477 ā€¦ 0.5627096043033888 0.43214393313605615; 0.005107555825969223 0.7667060072342782 ā€¦ 0.08102553389395828 0.3738361340817895; ā€¦ ; 0.21991757626344777 0.2650633914215146 ā€¦ 0.8480400033537479 0.39380618071394813; 0.15424713548386948 0.5033801812588259 ā€¦ 0.04211599433014168 0.4945127946146868]

julia> A[1]
5Ɨ5 Matrix{Float64}:
 0.467714  0.429285  0.116773  0.350455  0.909679
 0.229699  0.293745  0.227465  0.736049  0.179704
 0.48666   0.493857  0.506317  0.331685  0.743395
 0.869754  0.633566  0.916483  0.831438  0.274217
 0.455223  0.752233  0.269686  0.442151  0.651999
2 Likes

Many thanks, That will solve my issue.

1 Like