summaryrefslogtreecommitdiff
path: root/modules/signal_processing/macros/fftshift.sci
blob: b10dbc02383d5a5f0c252404b2bd56290c57dc8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt

function x = fftshift(x,job)
    if argn(2)<2 then job="all",end
    deff("sel=fun(sk)","c=ceil(sk/2);sel=[c+1:sk,1:c]")
    if job=="r" then job=1,elseif job=="c" then job=2,end
    ind=list()
    if job=="all" then
        for sk=size(x),ind($+1)=fun(sk),end
    else
        for sk=size(x),ind($+1)=:,end;
        ind(job)=fun(size(x,job))
    end
    x=x(ind(:))
endfunction