Why does running this function result in " Unexpected MATLAB operator" at the first line of measurment?
2 views (last 30 days)
Show older comments
function [ber, numBits]=chap4_ex02(EbNo, maxNumErrs, maxNumBits)
%%Constants
FRM=2400; % Size of bit frame
%%Modulation Mode
% ModulationMode=1; % QPSK
% ModulationMode=2; % QAM16
ModulationMode=2; %QAM64
k=2*ModulationMode; % Number of bits per modulation symbol
snr = EbNo + 10*log10(k);
noiseVar = 10.^(0.1.*(-snr)); % Compute noise variance
%%Processing loop: transmitter, channel model and receiver
numErrs = 0;
numBits = 0;
nS=0;
while ((numErrs < maxNumErrs) && (numBits < maxNumBits))
% Transmitter
u = randi([0 1], FRM,1); % Randomly generated input bits
t0 = Scrambler(u, nS); % Scrambler
t1 = Modulator(t0, ModulationMode); % Modulator
% Channel
c0 = AWGNChannel(t1, snr); % AWGN channel
% Receiver
r0 = DemodulatorSoft(c0, ModulationMode, noiseVar); % Demodulator
r1 = DescramblerSoft(r0, nS); % Descrambler
y = 0.5*(1-sign(r1)); % Recover output bits
% Measurements
numErrs = numErrs + sum(ỹ=u); % Update number of bit errors
numBits = numBits + FRM; % Update number of bits processed
% Manage slot number with each subframe processed
nS = nS + 2;
nS = mod(nS, 20);
end
%%Clean up & collect results
ber = numErrs/numBits; % Compute Bit Error Rate (BER)
0 Comments
Answers (2)
Sean de Wolski
on 29 Dec 2014
First:
numErrs = numErrs + sum(ỹ=u)
One = sign is assignment, so you are trying to assign u to y which is illegal. You probably mean y==u. Second, for some reason there is a ~ above the characters. This possibly comes from a different keyboard or from copying this from a website. I went ahead and retyped the line and it looks good now:
numErrs = numErrs + sum(y==u)
And, most importantly, the way I found this is because the code analyzer was flagging the line as red on the right hand side of the editor
0 Comments
Ashik Rai
on 31 Mar 2020
Its something like this actually.
numErrs = numErrs + sum(y ~= u);
0 Comments
See Also
Categories
Find more on Propagation and Channel Models 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!