声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 17123|回复: 47

[FFT] 分数阶傅立叶变换程序汇总(个人收集自网上)

  [复制链接]
发表于 2007-4-26 19:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
都是从网上收集来的,由于时间比较久,处处都忘记了,如果是谁的原创请和我联系,我在帖子中标出来的

第二楼:the fast fractional Fourier transform
程序参考下文中的算法
H.M. Ozaktas, M.A. Kutay, and G. Bozdagi.
Digital computation of the fractional Fourier transform.
IEEE Trans. Sig. Proc., 44:2141--2150, 1996.

第三楼:分数阶fourior变换的源码,主要用来处理线性调频信号

第四楼:离散分数阶傅立叶变换,算法参考
C. Candan, M.A. Kutay, and H.M. Ozaktas.
The discrete Fractional Fourier Transform.
IEEE Trans. Sig. Proc., 48:1329--1337, 2000

第五楼:the discrete fractional Fourier transform,算法参考:
S.-C. Pei, M.-H. Yeh, and C.-C. Tseng.
Discrete fractional Fourier-transform based on orthogonal projections.
IEEE Trans. Sig. Proc., 47(5):1335--1348, 1999.

第六楼:a demonstration programfor the previous three routines

第七楼: the discrete fractional Cosine transform,算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001

第八楼:the discrete fractional Sine transform,算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001

第九楼:test for Disfrct.m,算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001

第十楼:the rescaling preprocessing for the frft routine,详细情况参考
H.M. Ozaktas, M.A. Kutay, and G. Bozdagi.
Digital computation of the fractional Fourier transform.
IEEE Trans. Sig. Proc., 44:2141--2150, 1996.

[ 本帖最后由 simon21 于 2007-4-26 20:14 编辑 ]

点评

赞成: 4.5
赞成: 4
  发表于 2016-9-15 18:48
赞成: 5
  发表于 2014-3-26 15:41

评分

1

查看全部评分

回复
分享到:

使用道具 举报

 楼主| 发表于 2007-4-26 19:48 | 显示全部楼层
程序参考下文中的算法
H.M. Ozaktas, M.A. Kutay, and G. Bozdagi.
Digital computation of the fractional Fourier transform.
IEEE Trans. Sig. Proc., 44:2141--2150, 1996.

  1. function Faf = frft(f, a)
  2. % The fast Fractional Fourier Transform
  3. % input: f = samples of the signal
  4. %        a = fractional power
  5. % output: Faf = fast Fractional Fourier transform
  6. error(nargchk(2, 2, nargin));
  7. f = f(:);
  8. N = length(f);
  9. shft = rem((0:N-1)+fix(N/2),N)+1;
  10. sN = sqrt(N);
  11. a = mod(a,4);
  12. % do special cases
  13. if (a==0), Faf = f; return; end;
  14. if (a==2), Faf = flipud(f); return; end;
  15. if (a==1), Faf(shft,1) = fft(f(shft))/sN; return; end
  16. if (a==3), Faf(shft,1) = ifft(f(shft))*sN; return; end
  17. % reduce to interval 0.5 < a < 1.5
  18. if (a>2.0), a = a-2; f = flipud(f); end
  19. if (a>1.5), a = a-1; f(shft,1) = fft(f(shft))/sN; end
  20. if (a<0.5), a = a+1; f(shft,1) = ifft(f(shft))*sN; end
  21. % the general case for 0.5 < a < 1.5
  22. alpha = a*pi/2;
  23. tana2 = tan(alpha/2);
  24. sina = sin(alpha);
  25. f = [zeros(N-1,1) ; interp(f) ; zeros(N-1,1)];
  26. % chirp premultiplication
  27. chrp = exp(-i*pi/N*tana2/4*(-2*N+2:2*N-2)'.^2);
  28. f = chrp.*f;
  29. % chirp convolution
  30. c = pi/N/sina/4;
  31. Faf = fconv(exp(i*c*(-(4*N-4):4*N-4)'.^2),f);
  32. Faf = Faf(4*N-3:8*N-7)*sqrt(c/pi);
  33. % chirp post multiplication
  34. Faf = chrp.*Faf;
  35. % normalizing constant
  36. Faf = exp(-i*(1-a)*pi/4)*Faf(N:2:end-N+1);

  37. function xint=interp(x)
  38. % sinc interpolation
  39. N = length(x);
  40. y = zeros(2*N-1,1);
  41. y(1:2:2*N-1) = x;
  42. xint = fconv(y(1:2*N-1), sinc([-(2*N-3):(2*N-3)]'/2));
  43. xint = xint(2*N-2:end-2*N+3);

  44. function z = fconv(x,y)
  45. % convolution by fft
  46. N = length([x(:);y(:)])-1;
  47. P = 2^nextpow2(N);
  48. z = ifft( fft(x,P) .* fft(y,P));
  49. z = z(1:N);
复制代码


程序来自于http://www.cs.kuleuven.ac.be/cwi ... oftware/FRFT/frft.m
 楼主| 发表于 2007-4-26 19:51 | 显示全部楼层
分数阶fourior变换的源码,主要用来处理线性调频信号

  1. %DISCRETE FRACTIONAL FOURIER TRANSFORM MATRIX GENERATOR
  2. %by Cagatay Candan <[email]candan@ieee.org[/email]>, July 1998, Ankara
  3. %Copyright 1998 Cagatay Candan
  4. %This code may be used for scientific and educational purposes
  5. %provided credit is given to the publications below:
  6. %
  7. %This Matlab function generates the discrete fractional
  8. %Fourier transform matrix originally described in:
  9. %Cagatay Candan, M. Alper Kutay, and Haldun M. Ozaktas,
  10. %The discrete fractional Fourier Transform,
  11. %IEEE Transactions on Signal Processing, 48:1329-1337, May 2000,
  12. %(also in Proc ICASSP'99, pages 1713-1716, IEEE, 1999);
  13. %and further described in:
  14. %Haldun M. Ozaktas, Zeev Zalevsky, and M. Alper Kutay,
  15. %The Fractional Fourier Transform with Applications in Optics and
  16. %Signal Processing, Wiley, 2000, chapter 6.

  17. function F=dFRT(N,a,ord)
  18. %function F=dFRT(N,a,ord) returns the NxN discrete fractional
  19. %Fourier transform matrix with fractional order 'a'.
  20. %The optional argument 'ord' is the order of approximation
  21. %of the S matrix (default 2).

  22. %Note: This Matlab file has some subfunctions for generating S_{2k}
  23. %      matrices, eigenvector ordering etc. These functions are not
  24. %      visible from the Matlab workspace.

  25. global Evec Eval ordp

  26. if nargin==2, ord=2;end;

  27. if (length(Evec)~=N | ordp~=ord),
  28.     [Evec,Eval]=dis_s(N,ord);
  29.     ordp=ord;
  30. end;

  31. even=~rem(N,2);
  32. F=Evec*diag(exp(-j*pi/2*a*([0:N-2 N-1+even])))*Evec';

  33. %%%%%%

  34. function M=cconvm(v);
  35. %Generates circular Convm matrix

  36. v=v(:);N=length(v);
  37. M=zeros(N,N);dum=v;
  38. for k=1:N,
  39.     M(:,k)=dum;
  40.     dum=[dum(N); dum(1:N-1)];
  41. end;

  42. %%%%%%

  43. function S=creates(N,ord)
  44. %Creates S matrix of approximation order ord
  45. %When ord=1, elementary S matrix is returned

  46. ord=ord/2;
  47. dum=[1 -2 1];s=0;
  48. for k=1:ord,
  49.     s=(-1)^(k-1)*prod(1:(k-1))^2/prod(1:2*k)*2*[0 dum(k+2:2*k+1) zeros(1,N-1-2*k) dum(1:k)]+s;
  50.     dum=conv(dum,[1 -2 1]);
  51. end;
  52. S=cconvm(s)+diag(real(fft(s)));

  53. %%%%%%

  54. function [Evec,Eval]=dis_s(N,ord)
  55. %function [Evec,Eval]=dis_s(N)
  56. %Returns sorted eigenvectors and eigenvalues of corresponding vectors

  57. if nargin==1, ord=2;end;

  58. %%Construct S Matrix
  59. %S=diag(2*cos(2*pi/N*([0:N-1])))+diag(ones(1,N-1),1)+diag(ones(1,N-1),-1);
  60. %S(1,N)=1;S(N,1)=1;
  61. %%
  62. S=creates(N,ord);

  63. %%%%%%

  64. %Construct P matrix

  65. p=N;
  66. r=floor(p/2);
  67. P=zeros(p,p);

  68. P(1,1)=1;
  69. even=~rem(p,2);
  70. for k=1:r-even,
  71.     P(k+1,k+1)=1/sqrt(2);
  72.     P(k+1,p-(k+1)+2)=1/sqrt(2);
  73. end;

  74. if (even), P(r+1,r+1)=1; end;

  75. for k=r+1:p-1,
  76.     P(k+1,k+1)=-1/sqrt(2);
  77.     P(k+1,p-(k+1)+2)=1/sqrt(2);
  78. end;

  79. %%%%%%

  80. CS=P*S*P';C2=CS(floor(1:N/2+1),floor(1:N/2+1));S2=CS(floor(N/2+2):N,floor(N/2+2):N);

  81. [vc,ec]=eig(C2);[vs,es]=eig(S2);
  82. qvc=[vc ;zeros(ceil(N/2-1),floor(N/2+1))];
  83. SC2=P*qvc;    %Even Eigenvector of S

  84. qvs=[zeros(floor(N/2+1),ceil(N/2-1));vs];
  85. SS2=P*qvs;    %Odd Eigenvector of S

  86. es=diag(es);ec=diag(ec);
  87. [d,in]=sort(-ec);
  88. SC2=SC2(:,in);
  89. ec=ec(in);

  90. [d,in]=sort(-es);
  91. SS2=SS2(:,in);
  92. es=es(in);

  93. if rem(N,2)==0,
  94.     S2C2=zeros(N,N+1);
  95.     SS2(:,size(SS2,2)+1)=zeros(N,1);
  96.     S2C2(:,[0:2:N]+1)=SC2;
  97.     S2C2(:,[1:2:N]+1)=SS2;
  98.     S2C2(:,N)=[];
  99. else
  100.     S2C2=zeros(N,N);
  101.     S2C2(:,[0:2:N]+1)=SC2;
  102.     S2C2(:,[1:2:N-1]+1)=SS2;
  103. end;

  104. Evec=S2C2;
  105. Eval=(-j).^[ 0:N-2 (N-1)+even];

  106. %END
复制代码

评分

1

查看全部评分

 楼主| 发表于 2007-4-26 19:56 | 显示全部楼层
离散分数阶傅立叶变换- Separate score step Fourier transforms
算法参考
C. Candan, M.A. Kutay, and H.M. Ozaktas.
The discrete Fractional Fourier Transform.
IEEE Trans. Sig. Proc., 48:1329--1337, 2000

  1. function Fa=DFPei(f,a)

  2. % Compute discrete fractional Fourier transform
  3. % of order a of vector f according to Pei/Yeh/Tseng

  4. N=length(f); f=f(:);
  5. shft = rem((0:N-1)+fix(N/2),N)+1;

  6. global hn_saved p_saved
  7. if (nargin==2), p = 2; end;
  8. p = min(max(2,p),N-1);

  9. if (length(hn_saved) ~= N | p_saved ~= p),
  10.     hn = make_hn(N,p);
  11.     hn_saved = hn; p_saved = p;
  12. else
  13.     hn = hn_saved;
  14. end;
  15. Fa(shft,1)=hn*(exp(-j*pi/2*a*[0:N-1]).'.*(hn'*f(shft)));

  16. function hn = make_hn(N,p)
  17. even = rem(N,2)==0;
  18. shft = rem((0:N-1)+fix(N/2),N)+1;
  19. % Gauss-Hermite samples
  20. u = (-N/2:(N/2)-1)'/sqrt(N/2/pi);
  21. ex = exp(-u.^2/2);
  22. hn(:,1) = ex; r = norm(hn(:,1)); hn(:,1) = hn(:,1)/r;
  23. hn(:,2)=2*u.*ex; s = norm(hn(:,2)); hn(:,2) = hn(:,2)/s;
  24. r = s/r;
  25. for k = 3:N+1
  26.      hn(:,k)=2*r*u.*hn(:,k-1)-2*(k-2)*hn(:,k-2);
  27.      s = norm(hn(:,k)); hn(:,k) = hn(:,k)/s;
  28.      r=s/r;
  29. end
  30. if (even), hn(:,N)=[]; else, hn(:,N+1)=[]; end
  31. hn(shft,:) = hn;

  32. % eigenvectors of DFT matrix
  33. E = make_E(N,N/2);

  34. for k = 1:4
  35. if even % N even
  36.   switch k
  37.    case {1,3}
  38.     indx = k:4:N+1;
  39.     if (rem(N,4) ~= 0 && k==3) || (rem(N,4) == 0 && k==1),
  40.         indx(end) = indx(end)-1;
  41.     end
  42.    case {2,4}
  43.     indx = k:4:N-1;
  44.    end
  45. else % N odd
  46.    indx = k:4:N;
  47. end
  48. hn(:,k:4:N) = orth(E(:,indx)*E(:,indx)'*hn(:,indx));
  49. end

  50. function E = make_E(N,p)
  51. %Returns sorted eigenvectors and eigenvalues of corresponding vectors

  52. %Construct matrix H, use approx order ord

  53. d2 = [1 -2 1]; d_p = 1; s = 0; st = zeros(1,N);
  54. for k = 1:p/2,
  55.     d_p = conv(d2,d_p);
  56.     st([N-k+1:N,1:k+1]) = d_p; st(1) = 0;
  57.     s = s + (-1)^(k-1)*prod(1:(k-1))^2/prod(1:2*k)*2*st;        
  58. end;
  59. % H = circulant + diagonal
  60. col = (0:N-1)'; row = (N:-1:1);
  61. idx = col(:,ones(N,1)) + row(ones(N,1),:);
  62. st = [s(N:-1:2).';s(:)];
  63. H = st(idx)+diag(real(fft(s)));

  64. %Construct transformation matrix V

  65. r = floor(N/2);
  66. even = ~rem(N,2);
  67. V1 = (eye(N-1)+flipud(eye(N-1)))/sqrt(2);
  68. V1(N-r:end,N-r:end) = -V1(N-r:end,N-r:end);
  69. if (even), V1(r,r)=1; end
  70. V = eye(N); V(2:N,2:N) = V1;

  71. % Compute eigenvectors

  72. VHV = V*H*V';
  73. E = zeros(N);
  74. Ev = VHV(1:r+1,1:r+1);           Od = VHV(r+2:N,r+2:N);
  75. [ve,ee]=eig(Ev);                 [vo,eo]=eig(Od);
  76. %malab eig returns sorted eigenvalues
  77. %if different routine gives unsorted eigvals, then sort first
  78. %[d,inde] = sort(diag(ee));      [d,indo] = sort(diag(eo));
  79. %ve = ve(:,inde');               vo = vo(:,indo');
  80. E(1:r+1,1:r+1) = fliplr(ve);     E(r+2:N,r+2:N) = fliplr(vo);
  81. E = V*E;
  82. %shuffle eigenvectors
  83. ind = [1:r+1;r+2:2*r+2]; ind = ind(:);
  84. if (even), ind([N,N+2])=[]; else ind(N+1)=[]; end
  85. E = E(:,ind');
复制代码
本程序来自http://www.cs.kuleuven.ac.be/cwi ... ftware/FRFT/cdpei.m

[ 本帖最后由 simon21 于 2007-4-26 19:57 编辑 ]
 楼主| 发表于 2007-4-26 20:00 | 显示全部楼层
算法参考
S.-C. Pei, M.-H. Yeh, and C.-C. Tseng.
Discrete fractional Fourier-transform based on orthogonal projections.
IEEE Trans. Sig. Proc., 47(5):1335--1348, 1999.
  1. function y=Disfrft(f,a,p)
  2. % Computes discrete fractional Fourier transform
  3. % of order a of vector x
  4. % p (optional) is order of approximation, default N/2
  5. N = length(f); even = ~rem(N,2);
  6. shft = rem((0:N-1)+fix(N/2),N)+1;
  7. f = f(:);
  8. if (nargin==2), p = N/2; end;
  9. p = min(max(2,p),N-1);
  10. E = dFRFT(N,p);
  11. y(shft,1)=E*(exp(-j*pi/2*a*([0:N-2 N-1+even])).'.*(E'*f(shft)));

  12. function E=dFRFT(N,p)
  13. %function E=dFRFT(N,a,p) returns the NxN eigenvectors of the
  14. %Fourier transform matrix
  15. %The optional argument p is the order of approximation
  16. global E_saved p_saved
  17. if (length(E_saved) ~= N | p_saved ~= p),
  18.     E = make_E(N,p);
  19.     E_saved = E; p_saved = p;
  20. else
  21.     E = E_saved;
  22. end;

  23. function E = make_E(N,p)
  24. %Returns sorted eigenvectors and eigenvalues of corresponding vectors

  25. %Construct matrix H, use approx order ord
  26. d2 = [1 -2 1]; d_p = 1; s = 0; st = zeros(1,N);
  27. for k = 1:p/2,
  28.     d_p = conv(d2,d_p);
  29.     st([N-k+1:N,1:k+1]) = d_p; st(1) = 0;
  30.     temp = [1:k;1:k]; temp=temp(:)'./[1:2*k];
  31.     s = s + (-1)^(k-1)*prod(temp)*2*st;        
  32. end;
  33. % H = circulant + diagonal
  34. col = (0:N-1)'; row = (N:-1:1);
  35. idx = col(:,ones(N,1)) + row(ones(N,1),:);
  36. st = [s(N:-1:2).';s(:)];
  37. H = st(idx)+diag(real(fft(s)));
  38. %Construct transformation matrix V
  39. r = floor(N/2);
  40. even = ~rem(N,2);
  41. V1 = (eye(N-1)+flipud(eye(N-1)))/sqrt(2);
  42. V1(N-r:end,N-r:end) = -V1(N-r:end,N-r:end);
  43. if (even), V1(r,r)=1; end
  44. V = eye(N); V(2:N,2:N) = V1;
  45. % Compute eigenvectors
  46. VHV = V*H*V';
  47. E = zeros(N);
  48. Ev = VHV(1:r+1,1:r+1);           Od = VHV(r+2:N,r+2:N);
  49. [ve,ee]=eig(Ev);                 [vo,eo]=eig(Od);
  50. %malab eig returns sorted eigenvalues
  51. %if different routine gives unsorted eigvals, then sort first
  52. %[d,inde] = sort(diag(ee));      [d,indo] = sort(diag(eo));
  53. %ve = ve(:,inde');               vo = vo(:,indo');
  54. E(1:r+1,1:r+1) = fliplr(ve);     E(r+2:N,r+2:N) = fliplr(vo);
  55. E = V*E;
  56. %shuffle eigenvectors
  57. ind = [1:r+1;r+2:2*r+2]; ind = ind(:);
  58. if (even), ind([N,N+2])=[]; else ind(N+1)=[]; end
  59. E = E(:,ind');
复制代码

[ 本帖最后由 simon21 于 2007-4-26 20:08 编辑 ]
 楼主| 发表于 2007-4-26 20:09 | 显示全部楼层
a demonstration programfor the previous three routines

  1. x=0.0:0.02:2*pi; y =cos(x);
  2. clear p_saved hn_saved E_saved
  3. for a=0:0.05:4
  4.     fy=Disfrft(y,a);
  5.     fys=cdpei(y,a);
  6.     fyss=frft(y,a);
  7.     % blue,green,red,cyan
  8.     figure(1)
  9.     subplot(311);plot(x,real([fy,fys,fyss]));
  10.     title(['a = ',num2str(a)]);
  11.     subplot(312);plot(x,imag([fy,fys,fyss]));
  12.     subplot(313);plot(x,abs([fy,fys,fyss]));
  13.     pause(0.7);
  14. end
复制代码
 楼主| 发表于 2007-4-26 20:10 | 显示全部楼层
the discrete fractional Cosine

算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001
  1. function y = Disfrct(f,a,p)
  2. % Computes discrete fractional cosine transform
  3. % of order a of vector f
  4. % p (optional) is order of approximation, default N/2
  5. % S-C Pei, M-H Yeh, IEEE Tr SP 49(6)2001, pp.1198-1207
  6. N = length(f);
  7. shft = rem((0:N-1)+fix(N/2),N)+1;
  8. f = f(:);
  9. if (nargin==2), p = N/2; end;
  10. p = min(max(2,p),N-1);
  11. E = dFRCT(N,p);
  12. y=E*(exp(-j*pi*a*([0:N-1])).'.*(E'*f));

  13. function E=dFRCT(N,p)
  14. %function E=dFRCT(N,p) returns the NxN eigenvectors of the
  15. %Fourier Cosine transform matrix

  16. global EC_saved pC_saved

  17. if (length(EC_saved) ~= N | pC_saved ~= p),
  18.     E = make_EC(N,p);
  19.     EC_saved = E; pC_saved = p;
  20. else
  21.     E = EC_saved;
  22. end;

  23. function E = make_EC(N,p)
  24. % Returns sorted eigenvectors and eigenvalues of corresponding vectors
  25. % Construct matrix H, use approx order p
  26. N1=2*N-2;
  27. d2 = [1 -2 1]; d_p = 1; s = 0; st = zeros(1,N1);
  28. for k = 1:p/2,
  29.     d_p = conv(d2,d_p);
  30.     st([N1-k+1:N1,1:k+1]) = d_p; st(1) = 0;
  31.     temp = [1:k;1:k]; temp = temp(:)'./[1:2*k];
  32.     s = s + (-1)^(k-1)*prod(temp)*2*st;
  33. end;
  34. H = toeplitz(s(:),s)+diag(real(fft(s)));
  35. % Construct transformation matrix V
  36. V = [zeros(N-2,1),eye(N-2),zeros(N-2,1),flipud(eye(N-2))]/sqrt(2);
  37. V = [1,zeros(1,N1-1);V;zeros(1,N-1),1,zeros(1,N-2)];
  38. % Compute eigenvectors
  39. Ev = V*H*V';
  40. [ve,ee]=eig(Ev);
  41. % malab eig returns sorted eigenvalues
  42. % if different routine gives unsorted eigvals, then sort first
  43. % [d,inde] = sort(diag(ee));
  44. % ve = ve(:,inde');
  45. E = fliplr(ve);
  46. E(end,:) = E(end,:)/sqrt(2);
复制代码

[ 本帖最后由 simon21 于 2007-4-26 20:11 编辑 ]
 楼主| 发表于 2007-4-26 20:11 | 显示全部楼层
the discrete fractional Sine transform
算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001
  1. function y = Disfrst(f,a,p)
  2. % Computes discrete fractional sine transform
  3. % of order a of vector f
  4. % p (optional) is order of approximation, default N/2
  5. % S-C Pei, M-H Yeh, IEEE Tr SP 49(6)2001, pp.1198-1207
  6. N = length(f);
  7. shft = rem((0:N-1)+fix(N/2),N)+1;
  8. f = f(:);
  9. if (nargin==2), p = N/2; end;
  10. p = min(max(2,p),N-1);
  11. E = dFRST(N,p);
  12. y=E*(exp(-j*pi*a*([0:N-1])).'.*(E'*f));

  13. function E=dFRST(N,p)
  14. %function E=dFRST(N,p) returns the NxN eigenvectors of the
  15. %Fourier Sine transform matrix

  16. global ES_saved pS_saved

  17. if (length(ES_saved) ~= N | pS_saved ~= p),
  18.     E = make_ES(N,p);
  19.     ES_saved = E; pS_saved = p;
  20. else
  21.     E = ES_saved;
  22. end;

  23. function E = make_ES(N,p)
  24. % Returns sorted eigenvectors and eigenvalues of corresponding vectors
  25. % Construct matrix H, use approx order p
  26. N1=2*N+2;
  27. d2 = [1 -2 1]; d_p = 1; s = 0; st = zeros(1,N1);
  28. for k = 1:p/2,
  29.     d_p = conv(d2,d_p);
  30.     st([N1-k+1:N1,1:k+1]) = d_p; st(1) = 0;
  31.     temp = [1:k;1:k]; temp = temp(:)'./[1:2*k];
  32.     s = s + (-1)^(k-1)*prod(temp)*2*st;
  33. end;
  34. H = toeplitz(s(:),s)+diag(real(fft(s)));
  35. % Construct transformation matrix V
  36. r = N;
  37. V = [zeros(N,1),flipud(eye(N)),zeros(N,1),-eye(N)]/sqrt(2);
  38. % Compute eigenvectors
  39. Od = V*H*V';
  40. [vo,eo]=eig(Od);
  41. % malab eig returns sorted eigenvalues
  42. % if different routine gives unsorted eigvals, then sort first
  43. % [d,inde] = sort(diag(eo));
  44. % vo = vo(:,inde');
  45. E = flipud(fliplr(vo));
复制代码
 楼主| 发表于 2007-4-26 20:13 | 显示全部楼层
test for Disfrct.m
算法参考:
S.-C. Pei, M.-H. Yeh.
Discrete fractional Cosine and Sine transforms.
IEEE Trans. Sig. Proc., 49(6):1198--1207, 2001

  1. % Disfrft

  2. function testfrct(x)
  3. x=[-35:35];
  4. y = zeros(size(x));
  5. y(fix(length(x)/2)+1)=1;
  6. subplot(321),
  7. plot(x,y);
  8. title('symmetric delta')

  9. yf=Disfrft(y,5/6);
  10. subplot(322),
  11. plot(x,real(yf),'b',x,imag(yf),'r');
  12. axis([-32,32,-0.2,0.2]);
  13. title('FrFT for a = 5/6 of symmetric delta')

  14. % Disfrct

  15. x=[0:35];
  16. y1(1:1)=1;
  17. y1(2:36)=zeros(1,35);
  18. subplot(323),
  19. plot(x,y1)
  20. axis([0,35,0,1])
  21. title('half delta')

  22. yc=Disfrct(y1,5/6);
  23. subplot(324),
  24. plot(x,real(yc),'b',x,imag(yc),'r');
  25. axis([0,35,0-.2,0.2]);
  26. title('FrCT for a = 5/6 of half delta')

  27. % Disfrcst

  28. x=[-35:0];
  29. y1(1:36)=zeros(1,36);
  30. y1(1:1)=-1;
  31. subplot(325),
  32. plot(x,y1)
  33. axis([-35,0,-1,0])
  34. title('half delta')

  35. ys=Disfrst(y1,5/6);
  36. subplot(326),
  37. plot(x,real(ys),'b',x,imag(ys),'r');
  38. axis([-35,0,-.2,0.2]);
  39. title('FrST for a = 5/6 of half delta')
复制代码
 楼主| 发表于 2007-4-26 20:14 | 显示全部楼层
the rescaling preprocessing for the frft routine

算法参考:
H.M. Ozaktas, M.A. Kutay, and G. Bozdagi.
Digital computation of the fractional Fourier transform.
IEEE Trans. Sig. Proc., 44:2141--2150, 1996.
  1. function[signal,a_new,fact]=rescale(signal,a,delta_x1);
  2. % This routine calculates the parameters to transform the input for the
  3. % fractional Fourier transform when the support of the input
  4. % input is not N^2 with N=sqrt(length(signal))
  5. % Parameters: signal   = the signal to be transformed
  6. %             a        = the order of the transform
  7. %             delta_x1 = the length of the support of the input signal.
  8. % To compute the frft with these data use
  9. % Output:     signal = possibly flipped signal to avoid infinite factor
  10. %             a_new = compute the frft of order a_new
  11. %             fact = and elementwise multiply the result with fact
  12. N = length(signal);
  13. delta_x2 = sqrt(N);
  14. k = delta_x2/delta_x1;

  15. a_new =  mod(a,4);

  16. if k == 1 || a == 0
  17.   a_new = a;
  18.   fact = 1;
  19.   return
  20. elseif a == 2
  21.   signal = flipud(signal)
  22. else
  23.   phi = a*pi/2;
  24.   psi = acot(cot(phi)/k^2);
  25.   c = csc(phi)/(k*csc(psi));
  26.   x = linspace(-delta_x1/2,delta_x1/2,N);
  27.   u = x;
  28.   nu = c*u;
  29.   a_new = 2*psi/pi;
  30.   A_phi = exp(-i*(pi*sign(sin(phi))/4-phi/2))/sqrt(abs(sin(phi)));
  31.   A_psi = exp(-i*(pi*sign(sin(psi))/4-psi/2))/sqrt(abs(sin(psi)));
  32.   fact = A_phi/(k*A_psi)*exp(i*pi*(cot(phi)/c^2-cot(psi))*(nu.^2))';
  33. end;
复制代码

评分

1

查看全部评分

发表于 2008-4-4 17:50 | 显示全部楼层

谢谢

:handshake
:lol
发表于 2008-4-19 12:37 | 显示全部楼层

回复 10楼 的帖子

我看不太懂这个程序,感觉对输入输出参数的理解也很模糊,请清楚的同行解释一下此程序吧。
在调用frft.m程序前,需要事先调用此函数吗?
发表于 2008-4-19 16:59 | 显示全部楼层
。。。。。。。。。。好帖,留名。
发表于 2008-4-21 17:27 | 显示全部楼层
楼主有没有C的程序啊?急急急啊。
发表于 2008-4-29 15:14 | 显示全部楼层
晕死,看不懂,看来对信号这方面俺还是张白纸啊
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-28 05:56 , Processed in 0.227604 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表