Not enough input arguments.
Show older comments
% 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 %
Not enough input arguments.
Error in mQAM (line 6)
k = sqrt(1/((2/3)*(M-1))); % factor for normalizing energy %
Answers (1)
KSSV
on 2 Apr 2022
It seems, you are striaght away running the code using run/ F5 key.
Save your code into function, with the name mQAM.m, go the directory where the file is present.
M = define your variable ;
EsN0dB = define your value ;
% Now call the function
simSerMQAM = mQAM(M, EsN0dB) ;
7 Comments
Abdullah Kamuka
on 2 Apr 2022
KSSV
on 2 Apr 2022
You must be having idea on what M and other variables are.
KSSV
on 2 Apr 2022
No need to see. You need to provide inputs thats it.
Abdullah Kamuka
on 2 Apr 2022
It is working very fine.
EbN0dB = [-3:14]; % multiple Eb/N0 values %
M = 16 ;
simSerMQAM = mQAM(M,-3:14) ;
simSerMQAM
% 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 variance %
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(recSymsRe >max(alphaMqam)) = max(alphaMqam);
recSymsRe(recSymsRe <min(alphaMqam)) = min(alphaMqam);
% rounding to the nearest alphabet %
recSymsIm = 2*floor(tranSymsIm/2)+1;
recSymsIm(recSymsIm >max(alphaMqam)) = max(alphaMqam);
recSymsIm(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
Abdullah Kamuka
on 2 Apr 2022
Torsten
on 2 Apr 2022
Seems that
find(recPhase <0)
and
find(recPhase >0)
have a different number of elements.
Or is it just a typing error with the < and > signs ?
Categories
Find more on PHY Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!