Not enough input arguments.
이전 댓글 표시
% 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 %
답변 (1개)
KSSV
2022년 4월 2일
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
Abdullah Kamuka
2022년 4월 2일
KSSV
2022년 4월 2일
You must be having idea on what M and other variables are.
KSSV
2022년 4월 2일
No need to see. You need to provide inputs thats it.
Abdullah Kamuka
2022년 4월 2일
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
2022년 4월 2일
Torsten
2022년 4월 2일
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 ?
카테고리
도움말 센터 및 File Exchange에서 PHY Components에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!