Other/Summer/2025/mlCoexist: graph_w:o_cropping.m

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