Discrete Fourier Transform in MATLAB
For DFT
N=16;
K=0:15;
X_K=fft(x_n,N);
subplot(2,1,1);
stem(K,abs(X_K));
ylabel('Magnitude part');
subplot(2,1,2);
stem(K,angle(X_K));
ylabel('Phase part');
Code for the second question:
x_n=[2,1,2,1,1,2,1,2];
N=8;
K=0:7;
X_K=fft(x_n,N);
subplot(2,1,1);
stem(K,abs(X_K));
ylabel('Magnitude part');
subplot(2,1,2);
stem(K,angle(X_K));
ylabel('Phase part');
No comments