# A question about the Matrix

**URL:** <https://discourse.julialang.org/t/a-question-about-the-matrix/38123>\
**Category:** Optimization (Mathematical)\
**Tags:** question\
**Created:** [April 24, 2020, 3:31am UTC](https://discourse.julialang.org/t/a-question-about-the-matrix/38123 "2020-04-24T03:31:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abcde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abcde/32/16180_2.png) [@abcde](https://discourse.julialang.org/u/abcde)\
**Post date:** [April 24, 2020, 3:31am UTC](https://discourse.julialang.org/t/a-question-about-the-matrix/38123/1 "2020-04-24T03:31:00Z")

</div>

How do you define a matrix that doesn’t know how many rows and columns it has.  
thank you!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 24, 2020, 3:34am UTC](https://discourse.julialang.org/t/a-question-about-the-matrix/38123/2 "2020-04-24T03:34:56Z")

</div>

Size isn’t part of the matrix type. Only number of dimensions. `Matrix{T}` will be a matrix of type `T`.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [April 24, 2020, 3:49am UTC](https://discourse.julialang.org/t/a-question-about-the-matrix/38123/3 "2020-04-24T03:49:48Z")

</div>

The best way to do this is to use a `Vector` of `Vector`s.  
If you need a matrix, you can convert it at any time.

```julia

julia> vs = [[1, 2] ]
1-element Array{Array{Int64,1},1}:
 [1, 2]

julia> push!(vs, [3, 4])
2-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]

julia> push!(vs, [5, 6])
3-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]
 [5, 6]

julia> reduce(hcat, vs)
2×3 Array{Int64,2}:
 1 3 5
 2 4 6

```
