Use Default OFDM Sample Rate and Custom FFT Size
This example shows how the OFDM functions (nrOFDMModulate, nrOFDMInfo, and nrOFDMDemodulate) set the default value for the sample rate input, SampleRate, when you call an OFDM function and these conditions apply.
You do not specify a value for the
SampleRateinput, or you specify'SampleRate',[].You specify a custom value for the fast Fourier transform (FFT) size input,
Nfft.
Default OFDM Sample Rate
The default value set for the SampleRate input is equal to Nfft*carrier.SubcarrierSpacing*1000.
Custom FFT Size
The value that you set for the Nfft input must satisfy these conditions.
Nfftis an integer (to ensure integer-valued cyclic prefix lengths).Nfftis a power of 2.Nfftresults in a maximum occupancy of 100%. The actual occupancy is equal tocarrier.NSizeGrid*12/Nfft, wherecarrieris the input argument of the function call that specifies the carrier configuration.
Plot Bandwidth Occupancy
Create a carrier configuration object.
carrier = nrCarrierConfig;
Set the Nfft for each NSizeGrid value to give an occupancy of at most 90%.
nSizeGrids = 1:275; userNfftOccupancy = zeros(1,275); sampleRate = zeros(1,275); for nSizeGrid = nSizeGrids carrier.NSizeGrid = nSizeGrid; nfft = 128 * ceil(carrier.NSizeGrid*12/0.9/128); ofdmInfo = nrOFDMInfo(carrier,'Nfft',nfft); userNfftOccupancy(nSizeGrid) = carrier.NSizeGrid*12/ofdmInfo.Nfft; sampleRate(nSizeGrid) = ofdmInfo.SampleRate/1e6; end
Plot the resulting occupancy.
figure; plot(nSizeGrids,userNfftOccupancy,'x'); title({'Bandwidth Occupancy for Default Sample Rate' 'with FFT Size Selected for Maximum Occupancy of 90%'}); axis([1 275 0 1]); xlabel('NSizeGrid'); xticks([1 52 106 160 216 275]); ylabel('Bandwidth Occupancy (NSizeGrid * 12 / Nfft)');

Plot the resulting sample rate.
figure; plot(nSizeGrids,sampleRate,'x'); title({'Default Sample Rate' 'with FFT Size Selected for Maximum Occupancy of 90%'}); axis([1 275 0 max(sampleRate)]); xlabel('NSizeGrid'); xticks([1 52 106 160 216 275]); ylabel('Sample Rate (Ms/s)');
