clear all;
close all;
clc
Fc = 1.525e9 ; % Carrier frequency (Hz)
Rsym = 23400; % Symbol rate (symbols/second)
nSamps = 8; % Number of samples per symbol
frameLength = 2048; % Number of symbols in a frame
M = 16; % Modulation order (16-QAM)
EbNo = 15; % Ratio of baseband bit energy
% to noise power spectral density (dB)
% Calculate sampling frequency in Hz
Fs = Rsym * nSamps;
% Calculate passband SNR in dB. The noise variance of the baseband signal
% is double that of the corresponding bandpass signal [1]. Increase the SNR
% value by 10*log10(2) dB to account for this difference and have
% equivalent baseband and passband performance.
SNR = EbNo + 10*log10(log2(M)/nSamps) + 10*log10(2);
% Create a scatter plot scope for received symbols.
scatScope = commscope.ScatterPlot('SamplingFrequency', Rsym, ...
'SamplesPerSymbol', 1); close(scatScope)
% Create a 16-QAM modulator.
hMod = modem.qammod('M',M);
% Set the expected constellation of the scatter plot scope.
scatScope.Constellation = hMod.Constellation;
scatScope.PlotSettings.Constellation = 'on';
scatScope.PlotSettings.ConstellationStyle = '*r';
% Generate random data symbols.
b = randi([0 hMod.M-1], frameLength, 1);
% Modulate the random data.
txSym = modulate(hMod, b);
% Specify a square root raised cosine filter with a filter length of eight
% symbols and a rolloff factor of 0.2.
nSym = 8; % Length of the filter in symbols
beta = 0.2; % Rolloff factor
filterSpec = fdesign.pulseshaping(nSamps, 'Square root raised cosine', ...
'Nsym,Beta', nSym, beta);
% Design the transmitter filter.
hXmtFlt = design(filterSpec);
% Apply pulse shaping by upsampling and filtering. Alternatively, you can
% use an efficient multirate filter. See help for fdesign.interpolator for
% more information.
x = filter(hXmtFlt, upsample(txSym, nSamps));
% Plot spectrum estimate of pulse shaped signal.
figure;
pwelch(x,hamming(512),[],[],Fs,'centered')
% Generate carrier. The sqrt(2) factor ensures that the power of the
% frequency upconverted signal is equal to the power of its baseband
% counterpart.
t = (0:1/Fs:(frameLength/Rsym)-1/Fs).';
carrier = sqrt(2)*exp(1i*2*pi*Fc*t);
% Frequency upconvert to passband.
xUp = real(x.*carrier);
% Plot spectrum estimate.
pwelch(xUp,hamming(512),[],[],Fs,'centered')