function Faf = frft(f, a)8 u' V Q0 F$ m) |
% The fast Fractional Fourier Transform4 c2 Z) N- }% S& U
% input: f = samples of the signal6 |$ O' W" [1 q' @ a3 S
% a = fractional power
% output: Faf = fast Fractional Fourier transform
error(nargchk(2, 2, nargin));
f = f(
;
N = length(f);" N$ w( S) M4 T
shft = rem((0:N-1)+fix(N/2),N)+1;
sN = sqrt(N);
a = mod(a,4);
% do special cases3 ]- ]+ F6 d4 S6 Z. j* L
if (a==0), Faf = f; return; end;% R1 s3 T2 u3 ~9 m- E/ f
if (a==2), Faf = flipud(f); return; end;
if (a==1), Faf(shft,1) = fft(f(shft))/sN; return; end & y! N. b" }6 O. _: t, R0 k8 [/ h
if (a==3), Faf(shft,1) = ifft(f(shft))*sN; return; end
% reduce to interval 0.5 < a < 1.5
if (a>2.0), a = a-2; f = flipud(f); end0 S' u- R1 k8 r
if (a>1.5), a = a-1; f(shft,1) = fft(f(shft))/sN; end
if (a<0.5), a = a+1; f(shft,1) = ifft(f(shft))*sN; end
% the general case for 0.5 < a < 1.5
alpha = a*pi/2;
tana2 = tan(alpha/2);$ x9 G, I. S$ E+ c s4 b& T. @) Y, V
sina = sin(alpha);
f = [zeros(N-1,1) ; interp(f) ; zeros(N-1,1)];
% chirp premultiplication
chrp = exp(-i*pi/N*tana2/4*(-2*N+2:2*N-2)'.^2);' T7 [0 W& R' H! A5 _7 g5 _
f = chrp.*f;
% chirp convolution) m0 Z I9 R; x$ i5 w- p
c = pi/N/sina/4;
Faf = fconv(exp(i*c*(-(4*N-4):4*N-4)'.^2),f);6 j: v6 I' ?1 t* f
Faf = Faf(4*N-3:8*N-7)*sqrt(c/pi);
% chirp post multiplication- |0 L1 q/ W$ {
Faf = chrp.*Faf;
% normalizing constant
Faf = exp(-i*(1-a)*pi/4)*Faf(N:2:end-N+1);
%%%%%%%%%%%%%%%%%%%%%%%%%; H1 w' L: Q, {( P, O
function xint=interp(x): W: n7 d% n" s' a3 R/ U$ |
% sinc interpolation
N = length(x);# G$ z% M ^9 h" Z3 W8 S
y = zeros(2*N-1,1);+ x9 Q' W& a, Z
y(1:2:2*N-1) = x;( D( G3 z/ @5 p% H1 t9 q, w
xint = fconv(y(1:2*N-1), sinc([-(2*N-3)
2*N-3)]'/2));
xint = xint(2*N-2:end-2*N+3);
%%%%%%%%%%%%%%%%%%%%%%%%%
function z = fconv(x,y)- e4 C3 s0 k2 z" g- e& [* n
% convolution by fft
N = length([x(
;y(
])-1;
P = 2^nextpow2(N);, j. L, u% M* u5 X9 F3 ~# f+ b
z = ifft( fft(x,P) .* fft(y,P));% L4 `8 d4 q4 ?- o* q# V
z = z(1:N);
| 欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) | Powered by Discuz! X3.2 |