# Julia implementation of seqperiod (from MATLAB)

**URL:** <https://discourse.julialang.org/t/julia-implementation-of-seqperiod-from-matlab/66791>\
**Category:** Performance\
**Tags:** question\
**Created:** [August 21, 2021, 8:56pm UTC](https://discourse.julialang.org/t/julia-implementation-of-seqperiod-from-matlab/66791 "2021-08-21T20:56:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 21, 2021, 10:02pm UTC](https://discourse.julialang.org/t/julia-implementation-of-seqperiod-from-matlab/66791/2 "2021-08-21T22:02:54Z")

</div>

> [@MathGuy](#):
>
> `[abs.(x.-x[1])...]`

`vec(abs.(x .- x[1]))` is much better, you don’t want to splat huge amount of elements

> [@MathGuy](#):
>
> `maximum(abs.(x[ind1[i]:end].-x[1:end-ind1[i]+1])`

`@views maximum(abs, x[ind1[i]:end] .- x[1:end-ind1[i]+1])` should reduce some allocation for you. You can also turn this into a loop to eliminate allocation.

---

_[View the full topic](https://discourse.julialang.org/t/julia-implementation-of-seqperiod-from-matlab/66791)._
