summaryrefslogtreecommitdiff
path: root/macros/fftshift1.sci
blob: cdff99a63ba1f47ab8252bd22331a815ad5c0b98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function y= fftshift1(X,DIM)
//Perform a shift of the vector X, for use with the 'fft1' and 'ifft1' functions, in order the move the frequency 0 to the center of the vector or matrix.
//Calling Sequence
// fftshift1 (X)
// fftshift1 (X, DIM)
//Parameters 
//X:It is a vector of N elements corresponding to time samples
//DIM: The optional DIM argument can be used to limit the dimension along which the permutation occurs
//Description
//This is an Octave function.
//Perform a shift of the vector X, for use with the 'fft1' and 'ifft1' functions, in order the move the frequency 0 to the center of the vector or matrix.
//
//If X is a vector of N elements corresponding to N time samples spaced by dt, then 'fftshift1 (fft1 (X))' corresponds to frequencies
//
//f = [ -(ceil((N-1)/2):-1:1)*df 0 (1:floor((N-1)/2))*df ]
//
//where df = 1 / dt.
//
//If X is a matrix, the same holds for rows and columns.  If X is an array, then the same holds along each dimension.
//
//The optional DIM argument can be used to limit the dimension along which the permutation occurs.
	rhs= argn(2);
	if(rhs <1 | rhs >2)
		error('Wrong number of Input arguments');
	end
	select(rhs)
	case 1 then
		y=callOctave("fftshift",X);
	case 2 then
		y=callOctave("fftshift",X,DIM);
	end
endfunction