Skip to main content
Correcting blither
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94

One trick, for even-length signals, is what doto do with the "middle" sample. Here, I've split it half and half between each sizeside of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/202,xx2) plot([0:201]/202,xx2,'gx') plot([0:100]/101,x2,'r.') 

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/202,xx2) plot([0:201]/202,xx2,'gx') plot([0:100]/101,x2,'r.') 

One trick, for even-length signals, is what to do with the "middle" sample. Here, I've split it half and half between each side of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/202,xx2) plot([0:201]/202,xx2,'gx') plot([0:100]/101,x2,'r.') 
Get plots to line up in UPDATE.
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/200202,xx2) plot([0:201]/200202,xx2,'go''gx') plot([0:100]/100101,x2,'r.') 

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/200,xx2) plot([0:201]/200,xx2,'go') plot([0:100]/100,x2,'r.') 

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/202,xx2) plot([0:201]/202,xx2,'gx') plot([0:100]/101,x2,'r.') 
Added odd case
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/200,xx2) plot([0:201]/200,xx2,'go') plot([0:100]/100,x2,'r.') 

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here

One trick, for even-length signals, is what do do with the "middle" sample. Here, I've split it half and half between each size of the FFT.

The other trick is to ensure that you have the right amplitudes in the resampled signal. Here's it's a factor of 2.

Try this in scilab:

x = rand(1,100,'normal'); X = fft(x); XX = 2*[X(1:50) X(51)/2 zeros(1,99) X(51)/2 X(52:100)]; xx = ifft(XX); clf; plot([0:199]/200,xx) plot([0:199]/200,xx,'go') plot([0:99]/100,x,'r.') 

which appears to generate the right thing. The red dots are the original samples, and the green circles (and blue connecting lines) are the resampled data.

enter image description here


UPDATE

For the case of an odd number of samples, there are fewer fiddly bits (no splitting the last coefficient):

x2 = rand(1,101,'normal'); X2 = fft(x2); XX2 = 2*[X2(1:51) zeros(1,101) X2(52:101)]; xx2 = ifft(XX2); clf; plot([0:201]/200,xx2) plot([0:201]/200,xx2,'go') plot([0:100]/100,x2,'r.') 
Source Link
Peter K.
  • 26.3k
  • 9
  • 49
  • 94
Loading