SlideShare a Scribd company logo
1 of 7
Digital Communication Systems

                                              Homework # 6

                                         Muhammad Irfan Anjum



Matlab code is given in the Appendix.

BPSK Modulation      ±1

Sampling frequency fs= 2000 Hz

Sampling interval    T=1/fs

Symbol duration      Ts=20/fs



Problem # 1

       Matlab script to design root raised cosine filter p(kTs) with roll-off factor 0.5 and convolution of
two root raised cosine pulse is shown in fig. 1.

The graphs shown in Fig.1 are obtained using oversampling. It is clear from Fig.1 (b) that convolution of
two root raised cosine pulses is raise cosine pulse.



Problem # 2

       Fig. 2 shows the time and frequency plots of transmitted BPSK symbols before and after passing
through pulse shaping filter shown in Fig.1.



Problem # 3

       Fig. 3 shows the time and frequency plots of transmitted BPSK symbols before and after passing
through filter h(t), where h(t)=c(t)*p(t).
Fig.1
Fig. 2
Fig. 3



Problem # 4

         Fig. 4 shows the BER graphs of BPSK and 4-QAM modulations schemes in case of MLSD. It is
clear from the figure that BPSK performs better than 4-QAM in ISI channel.
Fig. 4



Appendix:

%% HomeWork#6, Digital Communication Systems...
clc
clear
close all
roll_off_factor=0.5;             % Rolloff factor.
fs=2000;                         % Sampling rrequency.
Ts=1/fs;                         % Sampling rate.
T=20/fs;                         % Symbol duration
M=10^5;                          % Number of symbols
interval=-T/2:Ts:T/2;
SNR=0:3:15;
%% Problem #1
Index=1;
for t=interval
    if t==0
         p(Index)=1-roll_off_factor+4*roll_off_factor/pi;
    elseif t== abs(Ts/(4*roll_off_factor))
p(Index)=roll_off_factor/sqrt(2) * ((1+2/pi)*sin(pi/
(4*roll_off_factor)) + (1-2/pi)*cos(pi/(4*roll_off_factor)));
    else
         N= sin(pi*t * (1-roll_off_factor)/Ts) + 4*roll_off_factor*t *
cos(pi*t*(1+roll_off_factor)/Ts)/Ts;
         D= pi*t * (1-(4*roll_off_factor*t/Ts)^2)/Ts;
         p(Index)=N/D;
    end
    Index=Index+1;
end
figure
subplot(211)
plot(interval,p);
xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Root
raised cosine filter'); grid on
p_kTs=conv(p,p);
hold on
interval=-T:Ts:T;
subplot(212)
plot(interval,p_kTs);
xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Raised
cosine filter'); grid on
axis ([-5*Ts 5*Ts -2 10])

%% Problem # 2

m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1
oversampled_data=upsample(m,T/Ts);
figure;
subplot(311);
stem(oversampled_data);
axis ([200 300 -2 2])
xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on

Tx=conv(oversampled_data,p);
subplot(312)
plot(Tx);
axis ([200 300 -2 2])
xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on
subplot(313);
spec_Tx=fft(Tx,length(Tx));
plot(abs(spec_Tx));
xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid
on

%% Problem #3

m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1
c=upsample([1 0.5 -0.1],T/Ts);
h=conv(c,p);
oversampled_data=upsample(m,T/Ts);
figure;
subplot(311);
stem(oversampled_data);
axis ([200 300 -2 2])
xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on
Tx=conv(oversampled_data,h);
subplot(312)
plot(Tx);
axis ([200 300 -2 2])
xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on
subplot(313);
spec_Tx=fft(Tx,length(Tx));
plot(abs(spec_Tx));
xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid
on

%% Problem #4 BPSK

[x y]=size(Tx);
j=1;
m=(m+1)/2;
for i=SNR
     sgma=sqrt(10^(-i/10));
     noise=random('Normal',0,sgma,x,y);
     Rx=noise+Tx;
     r_k=conv(Rx,fliplr(h));
     r=r_k(80:end-79);
     rx=sign(downsample(r,T/Ts));
     rx=(rx+1)/2;
     [N,ber]=biterr(m,rx);
     e_bpsk(j)=ber;
     j=j+1;
end
% Problem #4 4-QAM
rl=1/sqrt(2)*randsrc(M,1,[-1 1;0.5 0.5]); mg=1/sqrt(2)*randsrc(M,1,[-1 1;0.5
0.5]); % BPSK Symbols 1,-1
m=rl+mg*1j;                              % 4-QAM symbols
oversampled_data=upsample(m,T/Ts);
Tx=conv(oversampled_data,h);
[x y]=size(Tx); j=1;
rl=(sqrt(2)*rl+1)/2; mg=(sqrt(2)*mg+1)/2;
for i=SNR
     sgma=sqrt(10^(-i/10));
     noise=random('Normal',0,sgma,x,y)+random('Normal',0,sgma,x,y)*1j;
     Rx=noise+Tx;
     r_k=conv(Rx,fliplr(h));
     r=r_k(80:end-79);
     rxr=sign(downsample(real(r),T/Ts)); rxm=sign(downsample(imag(r),T/Ts));
     rxr=(rxr+1)/2; rxm=(rxm+1)/2;
     [N,ber1]=biterr(rl,rxr); [N,ber2]=biterr(mg,rxm);
     e_4qam(j)=(ber1+ber2)/2;
     j=j+1;
end
figure;
semilogy(SNR,e_bpsk,'-o');
hold on;
semilogy(SNR,e_4qam,'-*');
legend('BPSK', '4-QAM'); xlabel('SNR in dB'); ylabel('BER');
title('BER comparison of BPSK and 4-QAM in MLSD detector'); grid on

More Related Content

What's hot

Tele4653 l5
Tele4653 l5Tele4653 l5
Tele4653 l5
Vin Voro
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 review
gregcross22
 
Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2
Vin Voro
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5
Vin Voro
 
MATLAB program of expansion and compression of signal
MATLAB program of expansion and compression of signalMATLAB program of expansion and compression of signal
MATLAB program of expansion and compression of signal
Marmik Kothari
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wed
Vin Voro
 

What's hot (19)

Matlab code for comparing two microphone files
Matlab code for comparing two microphone filesMatlab code for comparing two microphone files
Matlab code for comparing two microphone files
 
Tele4653 l5
Tele4653 l5Tele4653 l5
Tele4653 l5
 
畳み込みについて
畳み込みについて畳み込みについて
畳み込みについて
 
Sampling and filtering
Sampling and filteringSampling and filtering
Sampling and filtering
 
Dsp final
Dsp finalDsp final
Dsp final
 
Exam 6 commlab 18_119_ei0292
Exam 6 commlab 18_119_ei0292Exam 6 commlab 18_119_ei0292
Exam 6 commlab 18_119_ei0292
 
The Inner Secrets of Compilers
The Inner Secrets of CompilersThe Inner Secrets of Compilers
The Inner Secrets of Compilers
 
Ff tand matlab-wanjun huang
Ff tand matlab-wanjun huangFf tand matlab-wanjun huang
Ff tand matlab-wanjun huang
 
Chapter 4 review
Chapter 4 reviewChapter 4 review
Chapter 4 review
 
K10692 control theory
K10692 control theoryK10692 control theory
K10692 control theory
 
Adaptive
AdaptiveAdaptive
Adaptive
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio files
 
Matlab Señales Discretas
Matlab Señales DiscretasMatlab Señales Discretas
Matlab Señales Discretas
 
Mpmc unit-string manipulation
Mpmc unit-string manipulationMpmc unit-string manipulation
Mpmc unit-string manipulation
 
Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5
 
MATLAB program of expansion and compression of signal
MATLAB program of expansion and compression of signalMATLAB program of expansion and compression of signal
MATLAB program of expansion and compression of signal
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wed
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 

Viewers also liked

Isi and nyquist criterion
Isi and nyquist criterionIsi and nyquist criterion
Isi and nyquist criterion
srkrishna341
 
Digital data transmission,line coding and pulse shaping
Digital data transmission,line coding and pulse shapingDigital data transmission,line coding and pulse shaping
Digital data transmission,line coding and pulse shaping
Aayush Kumar
 
Digital communication
Digital communication Digital communication
Digital communication
Akshay Joshi
 
Final project report
Final project reportFinal project report
Final project report
ssuryawanshi
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
Abi finni
 

Viewers also liked (17)

pulse shaping and equalization
pulse shaping and equalizationpulse shaping and equalization
pulse shaping and equalization
 
Isi and nyquist criterion
Isi and nyquist criterionIsi and nyquist criterion
Isi and nyquist criterion
 
Digital data transmission,line coding and pulse shaping
Digital data transmission,line coding and pulse shapingDigital data transmission,line coding and pulse shaping
Digital data transmission,line coding and pulse shaping
 
Matlab: Speech Signal Analysis
Matlab: Speech Signal AnalysisMatlab: Speech Signal Analysis
Matlab: Speech Signal Analysis
 
Simulation Study of FIR Filter based on MATLAB
Simulation Study of FIR Filter based on MATLABSimulation Study of FIR Filter based on MATLAB
Simulation Study of FIR Filter based on MATLAB
 
Designing a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate conceptDesigning a uniform filter bank using multirate concept
Designing a uniform filter bank using multirate concept
 
Digfilt
DigfiltDigfilt
Digfilt
 
FILTER BANKS
FILTER BANKSFILTER BANKS
FILTER BANKS
 
Matlab dsp examples
Matlab dsp examplesMatlab dsp examples
Matlab dsp examples
 
Gender detection using MATLAB
Gender detection using MATLABGender detection using MATLAB
Gender detection using MATLAB
 
Digital communication
Digital communication Digital communication
Digital communication
 
Pulse Shaping FIR Filter for WCDMA
Pulse Shaping FIR Filter for WCDMAPulse Shaping FIR Filter for WCDMA
Pulse Shaping FIR Filter for WCDMA
 
Final project report
Final project reportFinal project report
Final project report
 
DSP MATLAB notes - Akshansh
DSP MATLAB notes - AkshanshDSP MATLAB notes - Akshansh
DSP MATLAB notes - Akshansh
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
Introductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal ProcessingIntroductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal Processing
 
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank AnalysisMatlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
Matlab: Spectral Analysis, Fourier Analysis, Filterbank Analysis
 

Similar to Digitla Communication pulse shaping filter

Experiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384AdityabonnerjeeExperiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384Adityabonnerjee
AdityaBonnerjee21BEC
 

Similar to Digitla Communication pulse shaping filter (20)

DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLABDIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
DIGITAL SIGNAL PROCESSING: Sampling and Reconstruction on MATLAB
 
Solvedproblems 120406031331-phpapp01
Solvedproblems 120406031331-phpapp01Solvedproblems 120406031331-phpapp01
Solvedproblems 120406031331-phpapp01
 
Dsp gcu lab11
Dsp gcu lab11Dsp gcu lab11
Dsp gcu lab11
 
Comm lab manual_final-1
Comm lab manual_final-1Comm lab manual_final-1
Comm lab manual_final-1
 
Comm lab manual_final
Comm lab manual_finalComm lab manual_final
Comm lab manual_final
 
Experiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384AdityabonnerjeeExperiment3_DCS-21BEC0384Adityabonnerjee
Experiment3_DCS-21BEC0384Adityabonnerjee
 
Final ppt
Final pptFinal ppt
Final ppt
 
Frequency modulation
Frequency modulationFrequency modulation
Frequency modulation
 
Fhss project
Fhss projectFhss project
Fhss project
 
Frequency Modulation.ppt
Frequency Modulation.pptFrequency Modulation.ppt
Frequency Modulation.ppt
 
디지털통신 7
디지털통신 7디지털통신 7
디지털통신 7
 
DSP Lab 1-6.pdf
DSP Lab 1-6.pdfDSP Lab 1-6.pdf
DSP Lab 1-6.pdf
 
Lecture_ch6.pptx
Lecture_ch6.pptxLecture_ch6.pptx
Lecture_ch6.pptx
 
Decimation and Interpolation
Decimation and InterpolationDecimation and Interpolation
Decimation and Interpolation
 
dsp
dspdsp
dsp
 
data transmission
data transmission data transmission
data transmission
 
Unit IV_SS_MMS.ppt
Unit IV_SS_MMS.pptUnit IV_SS_MMS.ppt
Unit IV_SS_MMS.ppt
 
Modulation techniques matlab_code
Modulation techniques matlab_codeModulation techniques matlab_code
Modulation techniques matlab_code
 
Baseline Wandering
Baseline WanderingBaseline Wandering
Baseline Wandering
 
Lab01
Lab01Lab01
Lab01
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Digitla Communication pulse shaping filter

  • 1. Digital Communication Systems Homework # 6 Muhammad Irfan Anjum Matlab code is given in the Appendix. BPSK Modulation ±1 Sampling frequency fs= 2000 Hz Sampling interval T=1/fs Symbol duration Ts=20/fs Problem # 1 Matlab script to design root raised cosine filter p(kTs) with roll-off factor 0.5 and convolution of two root raised cosine pulse is shown in fig. 1. The graphs shown in Fig.1 are obtained using oversampling. It is clear from Fig.1 (b) that convolution of two root raised cosine pulses is raise cosine pulse. Problem # 2 Fig. 2 shows the time and frequency plots of transmitted BPSK symbols before and after passing through pulse shaping filter shown in Fig.1. Problem # 3 Fig. 3 shows the time and frequency plots of transmitted BPSK symbols before and after passing through filter h(t), where h(t)=c(t)*p(t).
  • 4. Fig. 3 Problem # 4 Fig. 4 shows the BER graphs of BPSK and 4-QAM modulations schemes in case of MLSD. It is clear from the figure that BPSK performs better than 4-QAM in ISI channel.
  • 5. Fig. 4 Appendix: %% HomeWork#6, Digital Communication Systems... clc clear close all roll_off_factor=0.5; % Rolloff factor. fs=2000; % Sampling rrequency. Ts=1/fs; % Sampling rate. T=20/fs; % Symbol duration M=10^5; % Number of symbols interval=-T/2:Ts:T/2; SNR=0:3:15; %% Problem #1 Index=1; for t=interval if t==0 p(Index)=1-roll_off_factor+4*roll_off_factor/pi; elseif t== abs(Ts/(4*roll_off_factor))
  • 6. p(Index)=roll_off_factor/sqrt(2) * ((1+2/pi)*sin(pi/ (4*roll_off_factor)) + (1-2/pi)*cos(pi/(4*roll_off_factor))); else N= sin(pi*t * (1-roll_off_factor)/Ts) + 4*roll_off_factor*t * cos(pi*t*(1+roll_off_factor)/Ts)/Ts; D= pi*t * (1-(4*roll_off_factor*t/Ts)^2)/Ts; p(Index)=N/D; end Index=Index+1; end figure subplot(211) plot(interval,p); xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Root raised cosine filter'); grid on p_kTs=conv(p,p); hold on interval=-T:Ts:T; subplot(212) plot(interval,p_kTs); xlabel('time-->'); ylabel('Amplitude'); title('Impulse response of Raised cosine filter'); grid on axis ([-5*Ts 5*Ts -2 10]) %% Problem # 2 m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1 oversampled_data=upsample(m,T/Ts); figure; subplot(311); stem(oversampled_data); axis ([200 300 -2 2]) xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on Tx=conv(oversampled_data,p); subplot(312) plot(Tx); axis ([200 300 -2 2]) xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on subplot(313); spec_Tx=fft(Tx,length(Tx)); plot(abs(spec_Tx)); xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid on %% Problem #3 m=randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1 c=upsample([1 0.5 -0.1],T/Ts); h=conv(c,p); oversampled_data=upsample(m,T/Ts); figure; subplot(311); stem(oversampled_data); axis ([200 300 -2 2]) xlabel('n'); ylabel('Amplitude'); title('oversampled data');grid on Tx=conv(oversampled_data,h);
  • 7. subplot(312) plot(Tx); axis ([200 300 -2 2]) xlabel('time'); ylabel('Amplitude'); title('Transmitted data');grid on subplot(313); spec_Tx=fft(Tx,length(Tx)); plot(abs(spec_Tx)); xlabel('f'); ylabel('Amplitude'); title('Spectrum of transmitted data');grid on %% Problem #4 BPSK [x y]=size(Tx); j=1; m=(m+1)/2; for i=SNR sgma=sqrt(10^(-i/10)); noise=random('Normal',0,sgma,x,y); Rx=noise+Tx; r_k=conv(Rx,fliplr(h)); r=r_k(80:end-79); rx=sign(downsample(r,T/Ts)); rx=(rx+1)/2; [N,ber]=biterr(m,rx); e_bpsk(j)=ber; j=j+1; end % Problem #4 4-QAM rl=1/sqrt(2)*randsrc(M,1,[-1 1;0.5 0.5]); mg=1/sqrt(2)*randsrc(M,1,[-1 1;0.5 0.5]); % BPSK Symbols 1,-1 m=rl+mg*1j; % 4-QAM symbols oversampled_data=upsample(m,T/Ts); Tx=conv(oversampled_data,h); [x y]=size(Tx); j=1; rl=(sqrt(2)*rl+1)/2; mg=(sqrt(2)*mg+1)/2; for i=SNR sgma=sqrt(10^(-i/10)); noise=random('Normal',0,sgma,x,y)+random('Normal',0,sgma,x,y)*1j; Rx=noise+Tx; r_k=conv(Rx,fliplr(h)); r=r_k(80:end-79); rxr=sign(downsample(real(r),T/Ts)); rxm=sign(downsample(imag(r),T/Ts)); rxr=(rxr+1)/2; rxm=(rxm+1)/2; [N,ber1]=biterr(rl,rxr); [N,ber2]=biterr(mg,rxm); e_4qam(j)=(ber1+ber2)/2; j=j+1; end figure; semilogy(SNR,e_bpsk,'-o'); hold on; semilogy(SNR,e_4qam,'-*'); legend('BPSK', '4-QAM'); xlabel('SNR in dB'); ylabel('BER'); title('BER comparison of BPSK and 4-QAM in MLSD detector'); grid on