Advertisement
makispaiktis

Course 9 - OFDM with equalizer (with IFFT also)

Aug 25th, 2023
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.46 KB | None | 0 0
  1. clear all
  2. close all
  3. clc
  4.  
  5.  
  6. % 1. Simulation parameters
  7.  
  8. modOrder = 16;  % for 16-QAM
  9. bitsPerSymbol = log2(modOrder);
  10. mpChan = [0.8; zeros(7,1); -0.5; zeros(7,1); 0.34];  % multipath channel
  11. SNR = 15;
  12.  
  13. % 2. Select number of bits - Each carrier holds a symbol and each symbol holds 4 bits
  14.  
  15. numCarr = 8192;
  16. numBits = numCarr * bitsPerSymbol;
  17.  
  18.  
  19. % 3. QAM Modulation
  20. srcBits = randi([0,1],numBits,1);
  21. qamModOut = qammod(srcBits,modOrder,"InputType","bit","UnitAveragePower",true);
  22.  
  23.  
  24. % 4. Select cyclic prefix length, so that it is at least equal to the FIR filter length, but as low as possible, because it will
  25. % contain data that will be discarded later. Cyclic prefix is needed to convert the signal into a periodic one. If a signal is
  26. % periodic, then linear and cyclic convolution are identical. Convolution "lies" at the receiver's edge, at equalizer.
  27.  
  28. cycPrefLen = 32;
  29.  
  30.  
  31. % 5. OFDM Modulation
  32. ofdmModOut = ofdmmod(qamModOut, numCarr, cycPrefLen);
  33.  
  34.  
  35. % 6. Channel
  36. pChanOut = filter(mpChan,1,ofdmModOut);
  37. chanOut = awgn(mpChanOut,SNR,"measured");
  38.  
  39.  
  40. % 7. OFDM Demodulation
  41. ofdmDemodOut = ofdmdemod(chanOut, numCarr, cycPrefLen);
  42. scatterplot(ofdmDemodOut);
  43.  
  44.  
  45. % 8. Equalizer
  46. mpChanFreq = fftshift(fft(mpChan,numCarr));
  47. eqOut = ofdmDemodOut ./ mpChanFreq;
  48. scatterplot(eqOut);
  49.  
  50.  
  51. % 9. QAM Demodulation
  52. qamDemodOut = qamdemod(eqOut,modOrder,"OutputType","bit","UnitAveragePower",true);
  53. numBitErrors = nnz(srcBits~=qamDemodOut)
  54. BER = numBitErrors/numBits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement