# Vector of Matrices of Varying Dimensions

**URL:** <https://discourse.julialang.org/t/vector-of-matrices-of-varying-dimensions/19819>\
**Category:** New to Julia\
**Created:** [January 19, 2019, 4:07pm UTC](https://discourse.julialang.org/t/vector-of-matrices-of-varying-dimensions/19819 "2019-01-19T16:07:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slakeon](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@slakeon](https://discourse.julialang.org/u/slakeon)\
**Post date:** [January 19, 2019, 4:07pm UTC](https://discourse.julialang.org/t/vector-of-matrices-of-varying-dimensions/19819/1 "2019-01-19T16:07:48Z")

</div>

Hi,

I am trying to program a simple Kalman Filter and Smoother that incorporates the possibility of partially missing observations in the observables vector. However, this would require to store arrays of varying dimensions. The innovations vector and the innovations covariance matrix are of time varying dimensions depending on which observations are available. What would be an efficient way to deal with this?

The third dimension of the arrays (one for the innovations and one for the covariance of the innovations) should be time, while the other two will depend on the specific situation.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 19, 2019, 10:07pm UTC](https://discourse.julialang.org/t/vector-of-matrices-of-varying-dimensions/19819/2 "2019-01-19T22:07:00Z")

</div>

> [@slakeon](#):
>
> this would require to store arrays of varying dimensions

I think that interesting keywords to use for searching existing solutions to this kind of problems are “ragged” or “non-rectangular” arrays.

One possibility is to actually have a vector of arrays (of possibly varying dimensions), _i.e_ a structure typed like `Vector{Array{T,2}}` for example. Then you can either use it directly (`a[i][j,k]`, where `i` indexes time, and bounds for `j,k` depend on `i`) or use tools such as [RecursiveArrayTools](https://github.com/JuliaDiffEq/RecursiveArrayTools.jl) to wrap your structure in an object which provides the same access as if it were a higher dimensional array (`a[i,j,k]`).

Another possibility is to directly use a data structure which supports ragged data. Packages like [RaggedData](https://github.com/tpapp/RaggedData.jl) or [RaggedArrays](https://github.com/ReidAtcheson/RaggedArrays.jl) seem to provide these kinds of features. There might be others.
