# How to create the set of variables as a matrix in stead of vector?

**URL:** <https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638>\
**Category:** General Usage\
**Tags:** ode, modelingtoolkit\
**Created:** [May 23, 2024, 6:03pm UTC](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638 "2024-05-23T18:03:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Post date:** [May 23, 2024, 6:03pm UTC](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638/1 "2024-05-23T18:03:21Z")

</div>

I have used the ModelingToolkit, DifferentialEquations, and OrdinaryDiffEq packages to solve the ODE system.  
In the past, I have implemented the set of variables x as a vector like:

```julia
@variables (x(t))[1:m]

```

Is there any way to implement the set of variables as a matrix instead of a vector? For I need the variables x as a m by m (m^2 variables in total).

Thank you for your time and consideration.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [May 23, 2024, 6:14pm UTC](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638/2 "2024-05-23T18:14:34Z")

</div>

This seemed to work for me? (I set `m=5`, hence the `1:5`)

```julia
julia> @variables z[1:m,1:m]
1-element Vector{Symbolics.Arr{Num, 2}}:
 z[1:5,1:5]

```

---

<div class="post-metadata">

**Author:** ![Ethan\_Tran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethan_tran/32/49198_2.png) [@Ethan\_Tran](https://discourse.julialang.org/u/Ethan_Tran)\
**Post date:** [May 23, 2024, 6:29pm UTC](https://discourse.julialang.org/t/how-to-create-the-set-of-variables-as-a-matrix-in-stead-of-vector/114638/3 "2024-05-23T18:29:22Z")

</div>

Thank you for your comment. I got the matrix of variables now.
