Files
2024-05-09 16:48:29 +08:00

21 lines
324 B
Matlab

N = 1e3 + 1;
f_c = 1e6;
t = linspace(0, pi / f_c, N);
f_s = 1 / N;
freqs = (0:N-1) / f_s;
x = exp(-1j * 2 * pi * f_c * t);
subplot(211);
plot(t, imag(x));
title("x(t) = sin(t)");
xlabel("t");
ylabel("x(t)");
x_fft = abs(fft(imag(x)));
subplot(212);
plot(t, x_fft);
title("X(f) = fft(x(t))");
xlabel("f");
ylabel("X(f)");