# Looping constructs, construct equations, ModelingToolkit

**URL:** https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568
**Category:** General Usage
**Tags:** question, package
**Created:** [May 24, 2022, 9:39am UTC](https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568 "2022-05-24T09:39:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Rohan\_Rajagopal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rohan_rajagopal/32/34183_2.png) [@Rohan\_Rajagopal](https://discourse.julialang.org/u/Rohan_Rajagopal)
#### Post date: [May 24, 2022, 9:39am UTC](https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568/1 "2022-05-24T09:39:18Z")

</div>

Is it possible to define equations using looping constructs, or is there a “correct” way to implement the following systems of equations,

```julia
N=3;
@parameters μ ϵ η_ω η_a A β[1:N] ω[1:N] θ[1:N, 1:N] 
@variables z[1:N^2+3*N + 1](t) D_train(..) P(t) W[1:N, 1:N](t)
eqs1 = [Equation(D_train(t), 2 * cos(4 * t + pi/2) + 1.5 * cos(8*t + pi/5) + 1.8 * cos(12 * t + pi/12))    

for i in 1:N
    for j in 1:N
        if i!=j
            D(W[i,j]) ~ A * (exp(im * z[9 + 3*(i-1) + j]/ω[j] )) 
    end
    W[i,i] ~ 0
end
]

```

Any help is deeply appreciated.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 24, 2022, 1:13pm UTC](https://discourse.julialang.org/t/looping-constructs-construct-equations-modelingtoolkit/81568/2 "2022-05-24T13:13:46Z")

</div>

It’s just an array. Just create and array of equations and fill it with a loop
