Code covered by the BSD License  

Highlights from
fshift

5.0

5.0 | 4 ratings Rate this file 16 Downloads (last 30 days) File Size: 1.34 KB File ID: #7886

fshift

by Francois Bouffard

 

21 Jun 2005 (Updated 07 Nov 2006)

Shifts the elements of an array by a (possibly non-integer) given number of elements.

| Watch this File

File Information
Description

FSHIFT shifts the elements in a vector by a given number of elements, as CIRCSHIFT does. However, a non-integer shift value can be used, in which case the elements are shifted along the perfect (sinc-based) interpolation of the periodisation of the vector. For integer shift values, FSHIFT is equivalent to CIRCSHIFT to machine precision.

The syntax to FSHIFT is slightly different from CIRCSHIFT (FSHIFT expects only vectors for its first argument and a scalar for its second argument). Also, the second arguments produces a shift in the opposite direction of CIRCSHIFT to be consistent with the usual statement of the shift property of the Fourier transform.

FSHIFT works by introducing a linear phase into the vector's DFT. As such, if there is a discontinuity between the first and last elements of the input vector, the output vector may present significant ringing.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
03 Jul 2008 Matlab User

Thanks, this was helpful

25 Apr 2009 Ahmed Fasih

I had to remove the following from the function: "if isreal(x); y = real(y); end;". With this gone, the output of the fft() of a complex exponential is exactly equal to an fshift()ed sinc().

22 Mar 2010 Joshua Carmichael

Helpful.
Two comments:
(1) Is the frequency domain shift appearing as:

exp(-1i*s*pi*f)';

Suppose to include a factor of 2 to be consistent with Matlab's definition of the fft, so that:

exp(-1i*s*2*pi*f)';

(2) Concatenate the input signal with it's flipped version, to make it even, to avoid forcing it to be real, then extract the latter half of the signal.

24 Mar 2010 Joshua Carmichael

Never mind, now that I have more carefully read your file, I see that covered the 2*pi factor in the frequency digitization and you are not forcing the signal to be real.

Please login to add a comment or rating.
Updates
07 Nov 2006

Bug fix: results for vectors with an even length were slightly off for non-integer shifts. Sorry for the inaccuracies that this could have caused.

Tag Activity for this File
Tag Applied By Date/Time
matrices Francois Bouffard 22 Oct 2008 07:50:56
circular Francois Bouffard 22 Oct 2008 07:50:56
shift Francois Bouffard 22 Oct 2008 07:50:56
noninteger Francois Bouffard 22 Oct 2008 07:50:56
fractional Francois Bouffard 22 Oct 2008 07:50:56
utilities Francois Bouffard 22 Oct 2008 07:50:56
fourier Ahmed Fasih 25 Apr 2009 12:16:43
dft Ahmed Fasih 25 Apr 2009 12:16:44
fft Ahmed Fasih 25 Apr 2009 12:16:44
delay Ahmed Fasih 25 Apr 2009 12:16:44
phase Ahmed Fasih 25 Apr 2009 12:16:44
fractional chaitanya reddy 25 Oct 2011 02:48:09

Contact us at files@mathworks.com