function pskevm()
Tnormal = 6/1625000; % Normal symbol duration in seconds
M = 8; % Modulation order (8-PSK)
burstLen1 = 174+78+174; % Number of symbols in the
% useful part of the burst
burstLen2 = burstLen1+9; % Number of symbols in the burst
numBursts = 200; % Number of bursts
Nsamp = 4; % Number of samples that represents a symbol
Fs = Nsamp/Tnormal; % Final sampling rate
SNR = 60; % Simulated signal-to-noise ratio in dB
% Create a 8-PSK comm.PSKModulator System object with 0 Phase Offset and
% user-defined symbol mapping.
hMod = comm.PSKModulator(8, 'PhaseOffset', 0, 'SymbolMapping', 'Custom');
hMod.CustomSymbolMapping = [7 3 2 0 1 5 4 6];
% Calculate the phase rotation vector
phaseRotation1 = exp(1i*(0:burstLen2-1)'*3*pi/8);
phaseRotation2 = exp(1i*(0:burstLen1-1)'*3*pi/8);
% Create a linearized GMSK pulse shaping filter
c0 = commEDGE_getLinearizedGMSKPulse(Nsamp);
hLinGMSK = dfilt.dffir(c0/max(c0));
% Create an comm.AWGNChannel System object. Set the NoiseMethod property of
% the channel to 'Signal to noise ratio (SNR)'.
hChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)',...
'SNR', SNR);
% Since the AWGN Channel system object as well as the RANDI function use
% the default random stream, the following commands are executed so that
% the results will be repeatable, i.e. same results will be obtained for
% every run of the demo. The default stream will be restored at the end of
% the demo.
s = RandStream.create('mt19937ar', 'seed',55408);
prevStream = RandStream.setGlobalStream(s);
% Design a raised cosine filter with roll off factor 0.25
Nsym = 8; % Filter order in symbols
beta = 0.25; % Roll-off factor
measFiltDef = fdesign.pulseshaping(Nsamp, 'Raised Cosine', ...
'Nsym,Beta', Nsym, beta, Nsamp/Tnormal);
hMeasFilt = design(measFiltDef);
% Apply the window and normalize the filter gain
w = commEDGE_getRaisedCosineWindow(Nsamp);
hMeasFilt.Numerator = hMeasFilt.Numerator.*w;
hEVM = comm.EVM('Normalization', 'Average reference signal power', ...
'MaximumEVMOutputPort', true, 'XPercentileEVMOutputPort',true)
% Calculate delays
refSigDelay = (length(hLinGMSK.Numerator) - 1) / 2;
delayXUptoS = (length(hMeasFilt.Numerator) - 1)/2;
rcvSigDelay = refSigDelay + delayXUptoS;
% Initialize total peak EVM
totalMaxEVM = 0;
maxRMSEVM = 0;
% Loop over bursts
for p=1:numBursts
% Generate random data
d = randi([0 M-1], burstLen2, 1);
% Modulate
x = step(hMod, d);
% Rotate phase
x = x .* phaseRotation1;
% Pulse shape
xUp = filter(hLinGMSK, upsample(x, Nsamp));
% Calculate input signal power and set the 'SignalPower' property
% of the AWGNChannel object
hChan.SignalPower = (xUp' * xUp)/ length(xUp);
% Add noise
r = step(hChan, xUp);
% Pass through the measurement filter
s = filter(hMeasFilt, r);
% Downsample both received and reference signals.
% Account for the filter delays
sd = s(rcvSigDelay+1:Nsamp:end);
xd = xUp(refSigDelay+1:Nsamp:end);
% Reset EVM object
reset(hEVM)
% Measure using the EVM system object
[rmsEVM,MaxEVM,PercentileEVM] = step(hEVM,(sd(1:burstLen1)), ...
(xd(1:burstLen1)));
% Update maximum RMS EVM
maxRMSEVM = max([maxRMSEVM rmsEVM]);
% Update maximum EVM sum
totalMaxEVM = totalMaxEVM + MaxEVM;
end
% Calculate peak EVM
peakEVM = totalMaxEVM / numBursts;
% Display results
fprintf(' Worst case RMS EVM (%%): %f\n', maxRMSEVM)
fprintf(' Peak EVM (%%): %f\n', peakEVM)
fprintf('95th percentile EVM (%%): %f\n', PercentileEVM)
% Restore default stream
RandStream.setGlobalStream(prevStream);
评论1