# Mirroring signal before fft

**URL:** https://discourse.julialang.org/t/mirroring-signal-before-fft/55749
**Category:** Signal and Image Processing
**Tags:** dsp
**Created:** [February 21, 2021, 11:13pm UTC](https://discourse.julialang.org/t/mirroring-signal-before-fft/55749 "2021-02-21T23:13:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chaseleslie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chaseleslie/32/22188_2.png) [@chaseleslie](https://discourse.julialang.org/u/chaseleslie)
#### Post date: [February 21, 2021, 11:13pm UTC](https://discourse.julialang.org/t/mirroring-signal-before-fft/55749/1 "2021-02-21T23:13:27Z")

</div>

I have inherited some code that mirrors a signal before taking the discrete Fourier transform of it, essentially like this:

```
signal = vcat(reverse(signal), signal)
# windowing and padding operations ...
sig = fft(signal)

```

I can imagine that this would have no effect on a perfect sinusoidal signal that is sampled at exactly one period. How might this affect other kinds of signals, such as high frequency components modulated on an exponential decay? Is there a reason to do this kind of mirroring before taking the discrete Fourier transform?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 21, 2021, 11:25pm UTC](https://discourse.julialang.org/t/mirroring-signal-before-fft/55749/2 "2021-02-21T23:25:13Z")

</div>

It’s equivalent to a discrete cosine transform, or at least similar (depending on what kind of padding etc you do).

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [February 22, 2021, 12:49am UTC](https://discourse.julialang.org/t/mirroring-signal-before-fft/55749/3 "2021-02-22T00:49:35Z")

</div>

Also of interest this abstract on [FFT input data flipping](https://www.google.com/url?sa=t&source=web&rct=j&url=https://s3.cern.ch/inspire-prod-files-6/60105cc4e40c4553acb168797ee011d9&ved=2ahUKEwjxgZ6wovzuAhXOy6QKHXQoA0cQFjAAegQIARAC&usg=AOvVaw2pdRNUx0w-fXT7TpJvnf5l)

---

<div class="post-metadata">

### Author: ![chaseleslie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chaseleslie/32/22188_2.png) [@chaseleslie](https://discourse.julialang.org/u/chaseleslie)
#### Post date: [February 22, 2021, 3:45am UTC](https://discourse.julialang.org/t/mirroring-signal-before-fft/55749/4 "2021-02-22T03:45:35Z")

</div>

Thanks stevengj and rafael.guerra for the responses. This has opened up some lines of inquiries.
