1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| close all; clear; clc;
fs = 24.576e3; fc = 10; f_if = 50; f_rf1 = 450; f_rf2 = 550;
N = 2 ^ 20; t = 0: 1/fs : 500; f = (-N/2 : N/2-1) * (fs/N);
i = cos(2 * pi * fc * t); q = 0.5 * sin(2 * pi * fc * t); s = i + 1j * q;
S = 10 * log10(fftshift(fft(s, N)));
figure; subplot(2, 2, 1); plot(t(1:32768), real(s(1:32768))); title('Digital Baseband Signal - Real Part'); xlabel('Time (s)'); ylabel('Amplitude');
subplot(2, 2, 3); plot(t(1:32768), imag(s(1:32768))); title('Digital Baseband Signal - Imaginary Part'); xlabel('Time (s)'); ylabel('Amplitude');
subplot(2, 2, 2); plot(f, real(S)); title('Digital Baseband Signal Spectrum - Real Part'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
subplot(2, 2, 4); plot(f, imag(S)); title('Digital Baseband Signal Spectrum - Imaginary Part'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
s_if = real(s .* (cos(2 * pi * f_if * t) + 1j * sin(2 * pi * f_if * t))); S_if = 10 * log10(fftshift(fft(s_if, N)));
figure; subplot(2, 1, 1); plot(t(1:32768), s_if(1:32768)); title('Intermediate Frequency (IF) Signal Waveform'); xlabel('Time (s)'); ylabel('Amplitude');
subplot(2, 1, 2); plot(f, real(S_if)); title('IF Signal Spectrum'); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
s_rf1 = s_if .* cos(2 * pi * f_rf1 * t); S_rf1 = 10 * log10(fftshift(fft(s_rf1, N))); s_rf2 = s_if .* cos(2 * pi * f_rf2 * t); S_rf2 = 10 * log10(fftshift(fft(s_rf2, N)));
figure; subplot(2, 2, 1); plot(t(1:32768), s_rf1(1:32768)); title(['RF Signal @ ', num2str(f_rf1), 'kHz - Waveform']); xlabel('Time (s)'); ylabel('Amplitude');
subplot(2, 2, 3); plot(f, real(S_rf1)); title(['RF Signal @ ', num2str(f_rf1), 'kHz - Spectrum']); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
subplot(2, 2, 2); plot(t(1:32768), s_rf2(1:32768)); title(['RF Signal @ ', num2str(f_rf2), 'kHz - Waveform']); xlabel('Time (s)'); ylabel('Amplitude');
subplot(2, 2, 4); plot(f, real(S_rf2)); title(['RF Signal @ ', num2str(f_rf2), 'kHz - Spectrum']); xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');
|