.st0{fill:#FFFFFF;}

5G in MATLAB 

 March 4, 2022

By  Ayush Sengupta

What is 5G?

The fifth-generation mobile network is referred to as 5G. It is a new worldwide wireless standard after 1G, 2G, 3G, and 4G networks. 5G allows for creating a new network that connects nearly everyone and everything, including machines, objects, and gadgets.

5G wireless technology is designed to provide multi-gigabit per second peak data rates, ultra-low latency, greater dependability, huge network capacity, increased availability, and a more consistent user experience to a larger number of users. Higher performance and efficiency allow for new user experiences and industry connections.

What is 5G

What is 5G

Difference between 4G and 5G?

The main difference between 4G and 5G is speed; 5G is substantially quicker than 4G, with reduced latency and more capacity. Every ten years, the cellular infrastructure that supports wireless communication is updated. Around the globe, 5G is gradually displacing 4G.

Overall, 5G promises to have more bandwidth, less latency, and more coverage globally than 4G.

What are uplink and downlink?

The Internet consists of an exchange of information between the satellite and the mobile phone/laptop/any electronic device used for communication. A wired or wireless connection from a local area network (LAN) to a wide area network (WAN) is referred to as an uplink in computer networking (WAN). A home router's uplink port is a particular kind of port that connects to a broadband modem (which is a LAN) and then to the Internet (which is a WAN). In satellite telecommunications, uplinks are extensively used to transmit satellite radio and television. Satellite uplink is how broadcasters send signal feeds from ground stations to orbiting satellites.

A downlink is a connection that runs in the opposite direction of an uplink, such as from a satellite to the ground or from an external network to a local network. Internet downloads, for example, use a downlink connection to reach the downloading device, while uploads use uplink connections.

Uplink and Downlink

Uplink and Downlink

Using the 5G Waveform Generator in MATLAB:

Under the "Apps" section, we will be using the 5G Waveform Generator Tool under the Signal Processing and Communications Toolbox. On opening it, we will get to see as below:

5G Toolbox in MATLAB

5G Toolbox in MATLAB

However, we will be changing some parameters to get the best 5G signal possible, having the most bandwidth and the least latency.

5G consists of 2 frequency bands:

  • FR1(410MHz-7GHz)
  • FR2(24GHz-52GHz)

We will be using the FR2 frequency, which is used in commercial deployments in Europe, China, Japan, Korea, and the US. The occupied bandwidth of a modulated waveform corresponds to the frequency range containing 99 percent of the total power of the modulated signal and is known as channel bandwidth.

For 5G FR2 frequency, the ideal channel bandwidth is 50 MHz. After entering the parameters, we click "Generate" and the spectrum is shown as follows:

Uplink:

Uplink

Uplink

Downlink:

Downlink

Downlink

MATLAB Code:

For Uplink:

% This script will show us the downlink spectrum of 5G having FR2 frequency
%%
%Author: Ayush Sengupta, MATLAB Helper
%Topic: 5G in MATLAB(Downlink)
%Website: https://MATLABHelper.com
%Date:06/01/2022

clear all;
close all;
%% Generate Uplink Waveform
% Uplink configuration:
cfgUL = nrULCarrierConfig('FrequencyRange', 'FR1', ...
'ChannelBandwidth', 50, ...
'NCellID', 1, ...
'NumSubframes', 10);

cfgUL.WindowingPercent = 0;
cfgUL.SampleRate = [];
cfgUL.CarrierFrequency = 0;

% SCS Carriers:
scs1 = nrSCSCarrierConfig( ...
'SubcarrierSpacing', 15, ...
'NSizeGrid', 270, ...
'NStartGrid', 3);
cfgUL.SCSCarriers = {scs1};

% Bandwidth Parts:
bwp1 = nrWavegenBWPConfig( ...
'BandwidthPartID', 1, ...
'Label', 'BWP1', ...
'SubcarrierSpacing', 15, ...
'CyclicPrefix', 'normal', ...
'NSizeBWP', 270, ...
'NStartBWP', 3);
cfgUL.BandwidthParts = {bwp1};

% PUSCH DMRS:
puschDMRS1 = nrPUSCHDMRSConfig( ...
'DMRSConfigurationType', 1, ...
'NumCDMGroupsWithoutData', 2, ...
'DMRSTypeAPosition', 2, ...
'DMRSAdditionalPosition', 0, ...
'DMRSLength', 1, ...
'CustomSymbolSet', [], ...
'DMRSPortSet', [], ...
'NIDNSCID', [], ...
'NSCID', 0, ...
'GroupHopping', 0, ...
'SequenceHopping', 0, ...
'NRSID', []);

% PUSCH PTRS:
puschPTRS1 = nrPUSCHPTRSConfig( ...
'TimeDensity', 1, ...
'FrequencyDensity', 2, ...
'NumPTRSSamples', 2, ...
'NumPTRSGroups', 2, ...
'REOffset', '00', ...
'PTRSPortSet', [], ...
'NID', []);

% PUSCH:
pusch1 = nrWavegenPUSCHConfig( ...
'Enable', true, ...
'Label', 'PUSCH1', ...
'Power', 0, ...
'BandwidthPartID', 1, ...
'Modulation', 'QPSK', ...
'NumLayers', 1, ...
'MappingType', 'A', ...
'SymbolAllocation', [0 14], ...
'SlotAllocation', [0 1 2 3 4 5 6 7 8 9], ...
'Period', 10, ...
'PRBSet', [0 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269], ...
'TransformPrecoding', false, ...
'TransmissionScheme', 'nonCodebook', ...
'NumAntennaPorts', 1, ...
'TPMI', 0, ...
'FrequencyHopping', 'neither', ...
'SecondHopStartPRB', 1, ...
'NID', 1, ...
'RNTI', 1, ...
'Coding', true, ...
'TargetCodeRate', 0.513671875, ...
'XOverhead', 0, ...
'RVSequence', [0 2 3 1], ...
'DataSource', 'PN9-ITU', ...
'EnableACK', false, ...
'NumACKBits', 10, ...
'BetaOffsetACK', 20, ...
'DataSourceACK', 'PN9-ITU', ...
'EnableCSI1', false, ...
'NumCSI1Bits', 10, ...
'BetaOffsetCSI1', 6.25, ...
'DataSourceCSI1', 'PN9-ITU', ...
'EnableCSI2', false, ...
'NumCSI2Bits', 10, ...
'BetaOffsetCSI2', 6.25, ...
'DataSourceCSI2', 'PN9-ITU', ...
'EnableCGUCI', false, ...
'NumCGUCIBits', 7, ...
'BetaOffsetCGUCI', 20, ...
'DataSourceCGUCI', 'PN9-ITU', ...
'EnableULSCH', true, ...
'UCIScaling', 1, ...
'DMRSPower', 0, ...
'EnablePTRS', false, ...
'PTRSPower', 0);
pusch1.DMRS = puschDMRS1;
pusch1.PTRS = puschPTRS1;
cfgUL.PUSCH = {pusch1};

% SRS:
srs1 = nrWavegenSRSConfig( ...
'Enable', false, ...
'Label', 'SRS1', ...
'Power', 0, ...
'BandwidthPartID', 1, ...
'NumSRSPorts', 1, ...
'NumSRSSymbols', 1, ...
'SymbolStart', 13, ...
'SlotAllocation', [0 1 2 3 4 5 6 7 8 9], ...
'Period', 10, ...
'KTC', 2, ...
'KBarTC', 0, ...
'CyclicShift', 0, ...
'FrequencyStart', 0, ...
'NRRC', 0, ...
'CSRS', 0, ...
'BSRS', 0, ...
'BHop', 0, ...
'Repetition', 1, ...
'GroupSeqHopping', 'neither', ...
'NSRSID', 0, ...
'SRSPositioning', false);
cfgUL.SRS = {srs1};

% waveform generation:
waveform = nrWaveformGenerator(cfgUL);

Fs = 6.144e+07; % sample rate of waveform

%% Visualize Uplink Waveform
% Spectrum Analyzer
spectrum = dsp.SpectrumAnalyzer('SampleRate', Fs);
spectrum(waveform);
release(spectrum);

For Downlink:

% This script will show us the downlink spectrum of 5G having FR2 frequency
%%
%Author: Ayush Sengupta, MATLAB Helper
%Topic: 5G in MATLAB(Downlink)
%Website: https://MATLABHelper.com
%Date:06/01/2022

clear all;
close all;
%% Generate Downlink Waveform
% Downlink configuration:
cfgDL = nrDLCarrierConfig('FrequencyRange', 'FR2', ...
'ChannelBandwidth', 50, ...
'NCellID', 1, ...
'NumSubframes', 10);

cfgDL.WindowingPercent = 0;
cfgDL.SampleRate = [];
cfgDL.CarrierFrequency = 0;

% SCS Carriers:
scs1 = nrSCSCarrierConfig( ...
'SubcarrierSpacing', 60, ...
'NSizeGrid', 66, ...
'NStartGrid', 3);
scs2 = nrSCSCarrierConfig( ...
'SubcarrierSpacing', 120, ...
'NSizeGrid', 32, ...
'NStartGrid', 2);
cfgDL.SCSCarriers = {scs1, scs2};

% Bandwidth Parts:
bwp1 = nrWavegenBWPConfig( ...
'BandwidthPartID', 1, ...
'Label', 'BWP1', ...
'SubcarrierSpacing', 60, ...
'CyclicPrefix', 'normal', ...
'NSizeBWP', 66, ...
'NStartBWP', 3);
cfgDL.BandwidthParts = {bwp1};

% SS Burst:
ssBurst1 = nrWavegenSSBurstConfig( ...
'BlockPattern', 'Case D', ...
'TransmittedBlocks', [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], ...
'Period', 20, ...
'NCRBSSB', [], ...
'KSSB', 0, ...
'DataSource', 'MIB', ...
'DMRSTypeAPosition', 2, ...
'CellBarred', false, ...
'IntraFreqReselection', false, ...
'PDCCHConfigSIB1', 0, ...
'SubcarrierSpacingCommon', 60, ...
'Enable', true, ...
'Power', 0);
cfgDL.SSBurst = ssBurst1;

% CORESET:
coreset1 = nrCORESETConfig( ...
'CORESETID', 0, ...
'Label', 'CORESET0', ...
'FrequencyResources', [1 1 1 1 1 1 1 1], ...
'Duration', 2, ...
'CCEREGMapping', 'interleaved', ...
'REGBundleSize', 6, ...
'InterleaverSize', 2, ...
'ShiftIndex', 0);
coreset2 = nrCORESETConfig( ...
'CORESETID', 1, ...
'Label', 'CORESET1', ...
'FrequencyResources', [1 1 1 1 1 1 1 1], ...
'Duration', 2, ...
'CCEREGMapping', 'interleaved', ...
'REGBundleSize', 6, ...
'InterleaverSize', 2, ...
'ShiftIndex', 0);
cfgDL.CORESET = {coreset1, coreset2};

% Search spaces:
searchSpaces1 = nrSearchSpaceConfig( ...
'SearchSpaceID', 1, ...
'Label', 'SearchSpace1', ...
'CORESETID', 1, ...
'SearchSpaceType', 'ue', ...
'StartSymbolWithinSlot', 0, ...
'SlotPeriodAndOffset', [1 0], ...
'Duration', 1, ...
'NumCandidates', [8 8 4 2 1]);
cfgDL.SearchSpaces = {searchSpaces1};

% PDCCH:
pdcch1 = nrWavegenPDCCHConfig( ...
'Enable', true, ...
'Label', 'PDCCH1', ...
'Power', 0, ...
'BandwidthPartID', 1, ...
'SearchSpaceID', 1, ...
'AggregationLevel', 8, ...
'AllocatedCandidate', 1, ...
'SlotAllocation', 0, ...
'Period', 1, ...
'Coding', true, ...
'DataBlockSize', 20, ...
'DataSource', 'PN9-ITU', ...
'RNTI', 1, ...
'DMRSScramblingID', 2, ...
'DMRSPower', 0);
cfgDL.PDCCH = {pdcch1};

% PDSCH DMRS:
pdschDMRS1 = nrPDSCHDMRSConfig( ...
'DMRSConfigurationType', 1, ...
'DMRSReferencePoint', 'CRB0', ...
'NumCDMGroupsWithoutData', 2, ...
'DMRSTypeAPosition', 2, ...
'DMRSAdditionalPosition', 0, ...
'DMRSLength', 1, ...
'CustomSymbolSet', [], ...
'DMRSPortSet', [], ...
'NIDNSCID', [], ...
'NSCID', 0);

% PDSCH PTRS:
pdschPTRS1 = nrPDSCHPTRSConfig( ...
'TimeDensity', 1, ...
'FrequencyDensity', 2, ...
'REOffset', '00', ...
'PTRSPortSet', []);

% PDSCH Reserved PRB:
pdschReserved1 = nrPDSCHReservedConfig( ...
'PRBSet', [], ...
'SymbolSet', [], ...
'Period', []);

% PDSCH:
pdsch1 = nrWavegenPDSCHConfig( ...
'Enable', true, ...
'Label', 'PDSCH1', ...
'Power', 0, ...
'BandwidthPartID', 1, ...
'Modulation', 'QPSK', ...
'NumLayers', 1, ...
'MappingType', 'A', ...
'ReservedCORESET', [], ...
'SymbolAllocation', [0 14], ...
'SlotAllocation', [0 1 2 3 4 5 6 7 8 9], ...
'Period', 10, ...
'PRBSet', [0 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], ...
'VRBToPRBInterleaving', false, ...
'VRBBundleSize', 2, ...
'NID', 1, ...
'RNTI', 1, ...
'Coding', true, ...
'TargetCodeRate', 0.513671875, ...
'TBScaling', 1, ...
'XOverhead', 0, ...
'RVSequence', [0 2 3 1], ...
'DataSource', 'PN9-ITU', ...
'DMRSPower', 0, ...
'EnablePTRS', false, ...
'PTRSPower', 0);
pdsch1.ReservedPRB{1} = pdschReserved1;
pdsch1.DMRS = pdschDMRS1;
pdsch1.PTRS = pdschPTRS1;
cfgDL.PDSCH = {pdsch1};

% CSI-RS:
csirs1 = nrWavegenCSIRSConfig( ...
'Enable', false, ...
'Label', 'CSIRS1', ...
'Power', 0, ...
'BandwidthPartID', 1, ...
'CSIRSType', 'nzp', ...
'CSIRSPeriod', 'on', ...
'RowNumber', 3, ...
'Density', 'one', ...
'SymbolLocations', 0, ...
'SubcarrierLocations', 0, ...
'NumRB', 52, ...
'RBOffset', 0, ...
'NID', 0);
cfgDL.CSIRS = {csirs1};

% waveform generation:
waveform = nrWaveformGenerator(cfgDL);

Fs = 6.144e+07; % sample rate of waveform

%% Visualize Downlink Waveform
% Spectrum Analyzer
spectrum = dsp.SpectrumAnalyzer('SampleRate', Fs);
spectrum(waveform);
release(spectrum);

What is dBm?

The decibels per milliwatt (dBm) unit of measurement is decibels per milliwatt. While dB is a dimensionless statement of gain, dBm is a physical measurement of the power level;  radio and audio frequencies are used to describe signal strength in wire and cables. dBm is a unit of measurement used to quantify extremely low values. The signal diminishes or weakens as it moves away from the tower. Any obstructions in the route, like buildings or trees, impact the signal. The signal is fairly strong when you are near the tower. It has a lower dBm when it gets to your house. A better than -70 dBm signal, measured in decibels, is regarded as good in all networks. In 3G networks, a weak signal will be -100 dBm or worse, while in 4G networks, it will be -110 dBm or worse.

In the 5G uplink and downlink spectrum, in the given range of frequency, the dBm is always above -60, with some minor spikes, so overall, 5G promises to be an excellent signal.

Conclusion:

5G is gradually spreading worldwide. We can use MATLAB to generate and analyze the 5G spectrum to get an idea of how better it is, compared to the existing 4G network. Some other features of 5G include:

  • Better mobile Internet- We will view new technologies like AR and VR with faster data, low latency, and lower cost.
  • With the help of high technology, it is possible to remotely control machinery such as vehicles and infrastructures.
  • It has scope for a massive IoT, providing low-cost connectivity solutions.

Get instant access to the code, model, or application of the video or article you found helpful! Simply purchase the specific title, if available, and receive the download link right away! #MATLABHelper #CodeMadeEasy

Ready to take your MATLAB skills to the next level? Look no further! At MATLAB Helper, we've got you covered. From free community support to expert help and training, we've got all the resources you need to become a pro in no time. If you have any questions or queries, don't hesitate to reach out to us. Simply post a comment below or send us an email at [email protected].

And don't forget to connect with us on LinkedIn, Facebook, and Subscribe to our YouTube Channel! We're always sharing helpful tips and updates, so you can stay up-to-date on everything related to MATLAB. Plus, if you spot any bugs or errors on our website, just let us know and we'll make sure to fix it ASAP.

Ready to get started? Book your expert help with Research Assistance plan today and get personalized assistance tailored to your needs. Or, if you're looking for more comprehensive training, join one of our training modules and get hands-on experience with the latest techniques and technologies. The choice is yours – start learning and growing with MATLAB Helper today!

Education is our future. MATLAB is our feature. Happy MATLABing!

About the author 

Ayush Sengupta

Hello,
I am an Electronics and Communication Engineer who is all set to explore different fields and contribute to everything. From writing blogs to making videos to programming, there is nothing else that excites me more!

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

MATLAB Helper ®

Follow: YouTube Channel, LinkedIn Company, Facebook Page, Instagram Page

Join Community of MATLAB Enthusiasts: Facebook Group, Telegram, LinkedIn Group

Use Website Chat or WhatsApp at +91-8104622179

>