n = 0:15;
x = exp(1j * 2 * pi * 0.1 * n);
X = fft(x);
figure;
subplot(3,1,1);
stem(n, real(x), 'r'); hold on;
stem(n, imag(x), 'b');
title('Complex Sinusoid'); xlabel('n'); ylabel('Amplitude');
legend('Real', 'Imaginary'); grid on;
subplot(3,1,2);
stem(abs(X), 'r');
title('Magnitude Spectrum'); xlabel('Frequency Index'); ylabel('|X(k)|');
grid on;
subplot(3,1,3);
stem(angle(X), 'b');
title('Phase Spectrum'); xlabel('Frequency Index'); ylabel('Phase (radians)');
grid on;
To embed this project on your website, copy the following code and paste it into your website's HTML: