1 | clc; clear all; close all;
|
---|
2 |
|
---|
3 | %% System Parameters
|
---|
4 | fc = 1442.5e6; % Center frequency
|
---|
5 | numRBGs = 4; % Number of RBGs
|
---|
6 | rbgSize = 8; % RBs per RBG
|
---|
7 | modulation = 'QPSK'; % Modulation scheme
|
---|
8 | numSubframes = 1; % Number of subframes
|
---|
9 | filenamePrefix = 'mimo_baseband';
|
---|
10 |
|
---|
11 | a = -0.276;
|
---|
12 | b = 0.317;
|
---|
13 | x = linspace(a, b, 10);
|
---|
14 | snum = 10;
|
---|
15 | gain_dB_list = [-20, -10, 0, 10, 20] + x(snum); % Gain levels in dB
|
---|
16 |
|
---|
17 | %% 5G NR Downlink Configuration
|
---|
18 | cfgDL = nrDLCarrierConfig;
|
---|
19 | cfgDL.ChannelBandwidth = 50; % MHz
|
---|
20 | cfgDL.FrequencyRange = 'FR1';
|
---|
21 | cfgDL.NumSubframes = numSubframes;
|
---|
22 | cfgDL.CarrierFrequency = fc;
|
---|
23 |
|
---|
24 | cfgDL.SCSCarriers{1}.SubcarrierSpacing = 15;
|
---|
25 | cfgDL.SCSCarriers{1}.NSizeGrid = 150;
|
---|
26 | cfgDL.BandwidthParts{1}.SubcarrierSpacing = 15;
|
---|
27 | cfgDL.BandwidthParts{1}.NSizeBWP = 150;
|
---|
28 |
|
---|
29 | % PRB allocation
|
---|
30 | rbIndices = 0:149;
|
---|
31 |
|
---|
32 | %% Loop over gains
|
---|
33 | nfft = 4096;
|
---|
34 | for g = 1:length(gain_dB_list)
|
---|
35 | gain_dB = gain_dB_list(g);
|
---|
36 | gain_linear = 10^(gain_dB/20);
|
---|
37 |
|
---|
38 | cfgDL.PDSCH = {};
|
---|
39 | pdsch = nrWavegenPDSCHConfig;
|
---|
40 | pdsch.Modulation = modulation;
|
---|
41 | pdsch.NumLayers = 1;
|
---|
42 | pdsch.PRBSet = rbIndices;
|
---|
43 | pdsch.SymbolAllocation = [0, 14];
|
---|
44 | cfgDL.PDSCH{1} = pdsch;
|
---|
45 |
|
---|
46 | % Generate waveform
|
---|
47 | [waveform, info] = nrWaveformGenerator(cfgDL);
|
---|
48 | waveform_scaled = gain_linear * waveform;
|
---|
49 | numSamples = size(waveform_scaled, 1);
|
---|
50 | fs = numSamples / (numSubframes * 1e-3);
|
---|
51 |
|
---|
52 | % Plot PSD
|
---|
53 | [psd, f] = pwelch(waveform_scaled, hamming(nfft), [], nfft, fs, 'centered');
|
---|
54 | f_abs = f + fc;
|
---|
55 |
|
---|
56 | % figure;
|
---|
57 | % plot(f_abs/1e6, 10*log10(psd));
|
---|
58 | % xlabel('Frequency (MHz)');
|
---|
59 | % ylabel('PSD (dB/Hz)');
|
---|
60 | % title(sprintf('PSD | Gain = %d dB', gain_dB));
|
---|
61 | % grid on;
|
---|
62 | % xline(1403, '--b', 'L-band Start');
|
---|
63 | % xline(1430, '--b', 'L-band End');
|
---|
64 |
|
---|
65 |
|
---|
66 | % Compute L-band Leakage
|
---|
67 | bandMask = (f_abs >= 1400e6) & (f_abs <= 1427e6);
|
---|
68 | f_band = f_abs(bandMask);
|
---|
69 | psd_band = psd(bandMask);
|
---|
70 | df = mean(diff(f_band));
|
---|
71 | P_watt = sum(psd_band) * df;
|
---|
72 | P_dBm = 10 * log10(P_watt / 1e-3);
|
---|
73 | wl = physconst('Lightspeed')/fc;
|
---|
74 |
|
---|
75 |
|
---|
76 | Pr_dbm = P_dBm + 5 + 12.84 + 20*log10(wl/(4*pi));
|
---|
77 | Prfi = 10 ^ ((Pr_dbm - 30)/10);
|
---|
78 |
|
---|
79 | Tb = (Prfi) / (physconst('Boltzmann') * 27 * 1e6);
|
---|
80 | fprintf('Gain = %.2f dB | Leaked Power into 1400–1427 MHz Band: %.2f dBm | Recieved Power: %.2f dBm\n', gain_dB, P_dBm, Pr_dbm);
|
---|
81 |
|
---|
82 | % Plot spectrogram
|
---|
83 | window = 512; noverlap = 256; nfft_spec = 1024;
|
---|
84 | [S,F,T,P] = spectrogram(waveform_scaled, window, noverlap, nfft_spec, fs, 'centered');
|
---|
85 |
|
---|
86 | % Plot
|
---|
87 | figure;
|
---|
88 | f_spec = F + fc;
|
---|
89 | freqMask = (f_spec >= 1400e6) & (f_spec <= 1427e6);
|
---|
90 | F_plot = f_spec(freqMask);
|
---|
91 | P_plot = P(freqMask);
|
---|
92 | imagesc(T*1e6, (F_plot)/1e6, 10*log10(abs(P_plot)));
|
---|
93 | % imagesc(T*1e6, (F+fc)/1e6, 10*log10(abs(P)));
|
---|
94 |
|
---|
95 | % freqMask = (F >= -22e6) & (F <= 22e6);
|
---|
96 | % F_plot = F(freqMask);
|
---|
97 | % P_plot = P(freqMask);
|
---|
98 | % imagesc(T*1e6, (F_plot)/1e6, 10*log10(abs(P_plot)));
|
---|
99 |
|
---|
100 | axis xy;
|
---|
101 | colormap jet;
|
---|
102 | colorbar;
|
---|
103 | clim([-170 -85]);
|
---|
104 | title(sprintf('Spectrogram | Gain = %d dB', round(gain_dB)));
|
---|
105 | xlabel('Time (\mus)');
|
---|
106 | ylabel('Frequency (MHz)');
|
---|
107 | % yline(1400, '-w', 'L-band Start');
|
---|
108 | % yline(1427, '-w', 'L-band End');
|
---|
109 | filename = sprintf('out_fc2_4RB_Gain%d_sn%d.png',round(gain_dB),snum);
|
---|
110 | saveas(gcf, filename);
|
---|
111 |
|
---|
112 | end
|
---|