# Julia code for 1-D discrete system

**URL:** <https://discourse.julialang.org/t/julia-code-for-1-d-discrete-system/54403>\
**Category:** Modelling & Simulations\
**Created:** [February 1, 2021, 6:20pm UTC](https://discourse.julialang.org/t/julia-code-for-1-d-discrete-system/54403 "2021-02-01T18:20:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![apo383](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/apo383/32/11272_2.png) [@apo383](https://discourse.julialang.org/u/apo383)\
**Post date:** [February 1, 2021, 10:58pm UTC](https://discourse.julialang.org/t/julia-code-for-1-d-discrete-system/54403/4 "2021-02-01T22:58:33Z")

</div>

The problem is that you are mixing scalar and array representations of state, plus `x1` is not defined:

```julia
logistic_eom(x, p, t) = SVector{1}(p[1]*x1)
state = zeros(1)

```

Note that `x1` is a scalar that doesn’t appear in the argument list, and `state` is a 1-D vector. You should follow @Datseris’s answer very closely, where `x` is a scalar and `f` returns a scalar.  
According to the [documentation](https://juliadynamics.github.io/DynamicalSystems.jl/dev/ds/general/):

> **Comment on 1-D**  
> One dimensional discrete systems expect the state always as a pure number, `0.8` instead of `SVector(0.8)` .

You’ll probably want `logistic_eom(x1,p,t) = p[1]*x1` to be consistent on both left and right-hand sides, and your initial state will also have to be scalar.

EDIT: Forgot to say try to format your code for readability and follow [these instructions](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757).

---

_[View the full topic](https://discourse.julialang.org/t/julia-code-for-1-d-discrete-system/54403)._
