M-ary PSK code from M-ary QAM code
28 views (last 30 days)
Show older comments
Hi all.
My professor has handed a code for the M-ary QAM
% function for realizing M-QAM modulation %
function simSerMQAM = mQAM(M, EsN0dB)
j = sqrt(-1); % imaginary unit %
numSim = 7*10^5; % number of simulation symbols %
k = sqrt(1/((2/3)*(M-1))); % factor for normalizing energy %
m = [1:sqrt(M)/2]; % alphabets %
alphaMqam = [-(2*m-1) 2*m-1];
errSymsQAM = zeros(1, length(EsN0dB));
for ii = 1:length(EsN0dB)
infoSyms = randsrc(1,numSim,alphaMqam) + j*randsrc(1,numSim,alphaMqam);
infoSymsQAM = k*infoSyms; % normalization of energy to 1 %
noise = 1/sqrt(2)*[randn(1,numSim) + j*randn(1,numSim)]; % white guassian noise, 0dB
tranSymsQAM = infoSymsQAM + 10^(-EsN0dB(ii)/20)*noise; % additive white gaussian noise %
% demodulation %
tranSymsRe = real(tranSymsQAM)/k; % real part %
tranSymsIm = imag(tranSymsQAM)/k; % imaginary part %
% rounding to the nearest alphabet %
recSymsRe = 2*floor(tranSymsRe/2)+1;
recSymsRe(find(recSymsRe >max(alphaMqam))) = max(alphaMqam);
recSymsRe(find(recSymsRe <min(alphaMqam))) = min(alphaMqam);
% rounding to the nearest alphabet %
recSymsIm = 2*floor(tranSymsIm/2)+1;
recSymsIm(find(recSymsIm >max(alphaMqam))) = max(alphaMqam);
recSymsIm(find(recSymsIm <min(alphaMqam))) = min(alphaMqam);
demoSyms = recSymsRe + j*recSymsIm;
% counting the number of symbol errors %
errSymsQAM(ii) = size(find([infoSyms - demoSyms]),2);
end
simSerMQAM = errSymsQAM/numSim;
end
%To run in command window
simSerMQAM = errSymsQAM/numSim;
end
and wants up to produce a M-ary PSK code based on that. Problem is, neither I nor anyone from my peer group can understand this code and I have been wracking my brains on this without knowing what to do. I am hoping that someone would be kind enough to shed light on this and what it does because I don't know what to do with it.
0 Comments
Answers (0)
See Also
Categories
Find more on PHY Components in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!