# Array and clocked signal

**URL:** https://discourse.julialang.org/t/array-and-clocked-signal/129778
**Category:** Modelling & Simulations
**Tags:** modelingtoolkit
**Created:** [June 10, 2025, 10:12am UTC](https://discourse.julialang.org/t/array-and-clocked-signal/129778 "2025-06-10T10:12:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yjr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yjr/32/207725_2.png) [@yjr](https://discourse.julialang.org/u/yjr)
#### Post date: [June 10, 2025, 10:12am UTC](https://discourse.julialang.org/t/array-and-clocked-signal/129778/1 "2025-06-10T10:12:18Z")

</div>

Hello,  
I m basically trying to implement a PRBS or similar signal generator using vector and discrete clock signal. But it does not seem that both can be handled simultaenously. Am I right or is there a way to use both ? Br

```using
using ModelingToolkit: t_nounits as t
dt = 0.1 # Sample interval
clock = Clock(dt) # A periodic clock with tick rate dt
k = ShiftIndex(clock)

@mtkmodel prbs_16 begin
    @variables begin
        state(t)[1:16] = rand(Bool,16) |> BitArray
        out(t)
        input(t)
    end
    @equations begin
        state[1](k-1) ~ state[2](k)
    end
end

# @named prbs=prbs_16()
@mtkbuild prbs=prbs_16()
ODEProblem(structural_simplify(prbs),tspan = (0.0, 10.0))
```

---

<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: [June 10, 2025, 2:08pm UTC](https://discourse.julialang.org/t/array-and-clocked-signal/129778/2 "2025-06-10T14:08:23Z")

</div>

Right now it cannot use both together. It should be giving you an error that says exactly that.

---

<div class="post-metadata">

### Author: ![yjr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yjr/32/207725_2.png) [@yjr](https://discourse.julialang.org/u/yjr)
#### Post date: [June 11, 2025, 1:26pm UTC](https://discourse.julialang.org/t/array-and-clocked-signal/129778/3 "2025-06-11T13:26:54Z")

</div>

Ok thanks for the answer, so I need a hint as I struggle … I just want to construct a block that outputs band limited white noise. So basically it shall update a variable each x.x seconds.  
I tried with a call back but as you only modify a value, an equation is needed for the variable and so it throws too many variables error. I tried using @dicrete\_events with

```julia
1 => x ~rand()

```

but it only evaluates rand the first time it is called …  
Any advice is welcome BR  
Yves-Julien Regamey
