I am trying to implement the discrete Fourier transform.Here is my code in MATLAB:
sym k
n = 1:4;
disp(n);
y = n-2>=0;
z = n-4>=0;
x = y-z;
X(k) = sum(x.*exp(-1i*2*pi*k.*n/4));
l = 1:4;
subplot(1,2,1);
stem(l,abs(X(l)));
subplot(1,2,2);
stem(l,angle(X(l)));
I get these results for magnitude and phase:
However when I try to put the values [0,1,1,0]
in this DFT calculator I don't get the same results. Where is the error in my code?