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

**URL:** <https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756>\
**Category:** General Usage\
**Tags:** question, arrays\
**Created:** [October 14, 2021, 1:19pm UTC](https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756 "2021-10-14T13:19:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 14, 2021, 1:19pm UTC](https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756/1 "2021-10-14T13:19:52Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 14, 2021, 1:39pm UTC](https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756/2 "2021-10-14T13:39:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [October 14, 2021, 1:42pm UTC](https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756/3 "2021-10-14T13:42:32Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 14, 2021, 1:45pm UTC](https://discourse.julialang.org/t/does-julia-have-something-equivalent-to-matlabs-cell-array/69756/4 "2021-10-14T13:45:22Z")

</div>

Many thanks, That will solve my issue.
