spm_dftmtx.m 945 B

123456789101112131415161718192021222324252627282930
  1. function C = spm_dftmtx(N,K,a)
  2. % Creates basis functions for Discrete Cosine Transform.
  3. % FORMAT C = spm_dftmtx(N,K,a)
  4. %
  5. % N - dimension
  6. % K - order
  7. % a - number of (1/2)5Hz frequency steps (default a = 2)
  8. %__________________________________________________________________________
  9. % spm_dftmtx creates a matrix for the first few basis functions of a one
  10. % dimensional discrete Fourier transform.
  11. %
  12. % See: Fundamentals of Digital Image Processing (p 150-154).
  13. % Anil K. Jain 1989.
  14. %__________________________________________________________________________
  15. % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
  16. % Karl Friston
  17. % $Id: spm_dftmtx.m 4170 2011-01-24 18:37:42Z karl $
  18. % initialise
  19. %--------------------------------------------------------------------------
  20. try, a; catch, a = 2; end
  21. C = ones(N,1);
  22. x = (0:(N - 1))/N;
  23. for k = 1:K
  24. C(:,end + 1) = sin(a*pi*k*x);
  25. C(:,end + 1) = cos(a*pi*k*x);
  26. end