function [F,u] = rdftI(f,x) % % RDFT % Roger's slow 1-D DFT function. % [F,u] = RFFT2(f,x) returns in F the 1-D Discrete % Fourier transform of the data in f defined over the % vector in x. The matrix u is a spatial % frequency variable and may be omitted. % % Note that this command is written for academic purposes % and is much slower than the FFT and FFT2 commands % which use a fast radix-2 type transform. % RJM 3/22/95 n = length(x); i=sqrt(-1); pi=3.141592653589793284626433; dx=(x(n)-x(1))/n; p=[0:n-1]'; for k= 1:n, Fmat=f.*exp(-i*2*pi*((k-1)/n*ones(n,1).*p)); % Above line performs all multiplications F(k) = 6.25*sum(Fmat)/n; % Above line adds up all the multiplications end % Now F contains the 1-D DFT. a1=ceil(n/2); a2=ceil(n/2+1); F = [ F(a2:n) F(1:a1)]; u=linspace(x(1)/dx,x(n)/dx,n);