Menu

[Solved] Following Piece Code Performs 8 Psk Modulator Demodulator Generates Large Number Random Nu Q37275139

The following piece of code performs 8-PSK modulator anddemodulator.

It generates large number of random number of bits and does 8PSKmodulation according to Grey coding. We then generate randomGaussian Noise and add it to 8PSK symbols. Then we demodulate thesignals based on the decision boundaries.

We then calculate the error rate for a range of SNR sweep.

Lab task is: Can you do the whole process forBPSK?

clear all close all clc % Generate a large number of bit-stream : num Bits 100000-1; seeda 1 = 1 ; rng (seedVal); dataBitsTxend error/numBits; BER = semilogy (SNRdB, BER) function dataSym - PSK8Mod (dataBit) numSym -ceil (length (dataBit)/3); dataSy

end end end function dataBit-PSK8Demod (dataSym) dataBit-[ for n = 1 : length (da tasvm) detectedBits anqleSymInRad-angle (da

elseif (anglesymInRad >- decBoundary6) & &(angleSymInRad decBoundary?) <= detectedBits[1 0 1]; elseif (angleSymInRad decBound

clear all close all clc % Generate a large number of bit-stream : num Bits 100000-1; seeda 1 = 1 ; rng (seedVal); dataBitsTx = randi (2,1, numBits)-1; % SNR sweep : SNRdB SNRLin10. (SNRdB/10); -10:2:10; % Do 8PSK modulation: dataSymsTx – PSK8Mod (dataBitsTx); % Generate AWGN : noise(1/sqrt (2)) (randn (1,ceil (numBits/3) randn (1,ceil (numBits/3))); 1i* for idxSNR -1 : length (SNRdB) % Data is corrupted by noise dataSymsRx – sqrt (SNRLin (idxSNR)) *dataSymsTx + noise; Do 8PSK demodulation: dataBitsRxDemodulatedBitsPSK8 Demod (dataSymsRx); % Calculate the Bit Error Rate: error (idx8NR) sum ( [dataBitsTx ~= dataBitsRxDemodulatedBits]) end error/numBits; BER = semilogy (SNRdB, BER) function dataSym – PSK8Mod (dataBit) numSym -ceil (length (dataBit)/3); dataSym for n-l:numSym p3-dataBit (3 n) p2-dataBit (3*n-1) pl -dataBit (3*n-2) % 000 if (pl0)&&(p20) &&(p3 0) datas ym (n)-exp (11+0);%45 degrees end % 001 if (pl0)&&(p20) & &(p3-1) dataSym (n)-exp (1ǐ*pi/4);%45 degrees end % 011 dataSym (n-exp (1i+p1/2);%45 degrees end % 010 datasym (n)-exp (1 i+3*pi/4);%45 degrees end % 110 dataSym(n)-exp (1 İ+pi);%45 degrees end datasym(n)-exp ( 1 ǐ * 5 *pi/4); % 45 degrees end % 101 datasym(n)-exp ( 1 i * 3*pi/2); % 45 degrees end % 100 dataSym (n)-exp (1i*7 pi/4):845 degrees end end end function dataBit-PSK8Demod (dataSym) dataBit-[ for n = 1 : length (da tasvm) detectedBits anqleSymInRad-angle (dataSym (n) if (angleSymInRad < 0) angleSym1nRad- 2*pi + angleSym1nRad; end decBoundaryl1*pi/8; decBoundary2 -3*pi/8; decBoundary3 5*pi/8; decBoundary4 -7 pi/8; decBoundary59*pi/8; decBoundary611*pi/8 decBoundary7-13*pi/8 decBoundary8-15*pi/8; if (angleSymInRaddecBoundary8)&&(angleSymInRad <- 2*pi) detectedBits-[0 0 0] elseif (angleSymInRad – 0)&&(angleSymInRad <- decBoundaryl) detectedBits-[0 0 0] elseif (angleSym1nRad>= decBoundaryl) && (angleSym1nRad decBoundary2) detectedBits = [0 0 1]; elseif (angleSymInRad decBoundary2)&&(angleSymInRad ← decBoundary3) detectedBits [0 1 1]; elseif (angleSymInRad >- decBoundary3) &&(angleSymInRad -decBoundary4) detectedBits[0 1 0]; elseif (angleSymInRad >- decBoundary4) &&(angleSymInRad decBoundary5) detectedBits[1 1 0]; elseif (angleSym1nRad >= decBoundary5) && (angleSymTnRad decBoundary6) detectedBits [1 1 1]; elseif (anglesymInRad >- decBoundary6) & &(angleSymInRad decBoundary?) <= detectedBits[1 0 1]; elseif (angleSymInRad decBoundary7) &&(angleSymInRad <- decBoundary8) detectedBits[1 0 0]; end dataBit- [dataBit detectedBits]; end end Show transcribed image text clear all close all clc % Generate a large number of bit-stream : num Bits 100000-1; seeda 1 = 1 ; rng (seedVal); dataBitsTx = randi (2,1, numBits)-1; % SNR sweep : SNRdB SNRLin10. (SNRdB/10); -10:2:10; % Do 8PSK modulation: dataSymsTx – PSK8Mod (dataBitsTx); % Generate AWGN : noise(1/sqrt (2)) (randn (1,ceil (numBits/3) randn (1,ceil (numBits/3))); 1i* for idxSNR -1 : length (SNRdB) % Data is corrupted by noise dataSymsRx – sqrt (SNRLin (idxSNR)) *dataSymsTx + noise; Do 8PSK demodulation: dataBitsRxDemodulatedBitsPSK8 Demod (dataSymsRx); % Calculate the Bit Error Rate: error (idx8NR) sum ( [dataBitsTx ~= dataBitsRxDemodulatedBits])
end error/numBits; BER = semilogy (SNRdB, BER) function dataSym – PSK8Mod (dataBit) numSym -ceil (length (dataBit)/3); dataSym for n-l:numSym p3-dataBit (3 n) p2-dataBit (3*n-1) pl -dataBit (3*n-2) % 000 if (pl0)&&(p20) &&(p3 0) datas ym (n)-exp (11+0);%45 degrees end % 001 if (pl0)&&(p20) & &(p3-1) dataSym (n)-exp (1ǐ*pi/4);%45 degrees end % 011 dataSym (n-exp (1i+p1/2);%45 degrees end % 010 datasym (n)-exp (1 i+3*pi/4);%45 degrees end % 110 dataSym(n)-exp (1 İ+pi);%45 degrees end datasym(n)-exp ( 1 ǐ * 5 *pi/4); % 45 degrees end % 101 datasym(n)-exp ( 1 i * 3*pi/2); % 45 degrees end % 100 dataSym (n)-exp (1i*7 pi/4):845 degrees
end end end function dataBit-PSK8Demod (dataSym) dataBit-[ for n = 1 : length (da tasvm) detectedBits anqleSymInRad-angle (dataSym (n) if (angleSymInRad – decBoundary4) &&(angleSymInRad decBoundary5) detectedBits[1 1 0]; elseif (angleSym1nRad >= decBoundary5) && (angleSymTnRad decBoundary6) detectedBits [1 1 1];
elseif (anglesymInRad >- decBoundary6) & &(angleSymInRad decBoundary?)

Expert Answer


Answer to The following piece of code performs 8-PSK modulator and demodulator. It generates large number of random number of bits… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *