# DSP.jl Resampled signal length doesn't match upsampling factor

**URL:** https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036
**Category:** Signal and Image Processing
**Tags:** dsp
**Created:** [March 16, 2020, 9:02am UTC](https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036 "2020-03-16T09:02:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![meritwagner](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@meritwagner](https://discourse.julialang.org/u/meritwagner)
#### Post date: [March 16, 2020, 9:02am UTC](https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036/1 "2020-03-16T09:02:24Z")

</div>

Hey guys,

I ran into a problem, while trying out the resampling algorithm from the DSP package (v0.6.3).  
First I just create a test array with random numbers between 1 and 2. My plan is then to resample up by factor of 10. Apart from being very happy with the speed of that especially with the @threads macro, my output vectors have the length of 99.999.995 instead of 100.000.000. Anybody have an idea why that is?

```julia
x=rand(10000000,4).+1;

function Resample(sig)
    res=DSP.resample(sig,10);
    return res
end 

@time Threads.@threads for i in (1:size(x)[2])
    x_resampled=Resample(x[:,i])
end

```

Thanks and best regards,  
Merit

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [March 16, 2020, 10:30am UTC](https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036/2 "2020-03-16T10:30:19Z")

</div>

First, try with a shorter vector and smaller degree of upsamplimg. These huge numbers just make things more confusing.

I would also guess (not knowing anything about this function) that it doesn’t necessarily extrapolate. So upsampling a length 10 vector by 2 should give a length 19 vector.

Try different lengths and factors and see what makes sense. Plot and inspect visually, etc. Pay particular attention to what happens near the beginning and end.

---

<div class="post-metadata">

### Author: ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)
#### Post date: [March 16, 2020, 11:56am UTC](https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036/3 "2020-03-16T11:56:48Z")

</div>

This is a known issue and I agree it’s not ideal.

[https://github.com/JuliaDSP/DSP.jl/issues/186](https://github.com/JuliaDSP/DSP.jl/issues/186)

-s

---

<div class="post-metadata">

### Author: ![meritwagner](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@meritwagner](https://discourse.julialang.org/u/meritwagner)
#### Post date: [March 17, 2020, 4:50pm UTC](https://discourse.julialang.org/t/dsp-jl-resampled-signal-length-doesnt-match-upsampling-factor/36036/4 "2020-03-17T16:50:31Z")

</div>

Thanks for the answers, the output of the resampling seems good though except that its missing a couple values. Maybe it will get fixed sometimes…

@DNF:  
I tried it before with much smaller Vectors, but same problem there.

Best, Merit
