#### darktronic

##### Newbie level 6

I've been trying to implementing this dft formula using fft:

for w = 1:N

f(w) = 0;

for q = 1:N

f(w) = f(w) + x2(q)*exp(1i*2*pi*p(q)*w/N);

end

end

where f is the frequency response of x2. Signal p is an array with same length as x2.

I found this code where it is a radix-2 fft algorithm to implement a traditional DFT.

function y = fft_rec(x)

n = length(x);

if n == 1

y = x;

else

m = n/2;

y_top = fft_rec(x(1:2n-1)));

y_bottom = fft_rec(x(2:2:n));

d = exp(-2 * pi * i / n) .^ (0:m-1);

z = d .* y_bottom;

y = [ y_top + z , y_top - z ];

end

any ideas how to modified it to make it applicable to my DFT formula above?

Any help will be greatly appreciated. Thanks