0% found this document useful (0 votes)
23 views4 pages

Project 4

File
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Project 4

File
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Contents

Transmitter
Plotting the transmitted signal

Channel (Noise is added)


Eye diagram at the output of the channel
Eye diagram at the filtered signal

plot BER vs. RC Filter Bandwidth

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Project 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% initial operations
close all
clear all
clc;
rng('default');

% Common parameters *******************************************************

% Measurement units:
% frequencies in MHz, bit rates in Mbit/s, time in micro-sec
Rb = 100; % Bit rate - 100 Mbit/s
Tb = 1/Rb; % bit interval
Nb = 1; % Bits per Symbol
Ns = 8; % Samples per symbol (bits)
Ts = Tb/Ns; % Sampling interval
fs = 1/Ts; % Sampling frequency
K = 40; % number of symbols (bits) in each segment
N = K*Ns; % number of samples for each signal segment
M = 200; % number of simulated signal segments
T = N*Ts; % duration of each segment
NTotBit = M*K; % Number of bits to be simulated
% NTotBit = 1000;
A=2; SNRdbvec=[-2 0 2]; SNRvec=10.^(SNRdbvec./10); Bvec=linspace(Rb/10,Rb,37);

Transmitter

[SignalTX,BitsTX] = Binary_Transmitter(NTotBit,Ns); % TX is generated


SignalTX=A*SignalTX; % amplitude is changed
Px=mean(abs(SignalTX).^2); % measuring power of transmitted signal (TX)

Plotting the transmitted signal

figure; plot(SignalTX(1:10*Ns)); grid on; title('Transmitted Signal');


eyediagram(SignalTX,3*Ns,3*Ns); % plotting eye diagram

MatrixTX=reshape(SignalTX,N,M);
MatrixTXFFT=fft(MatrixTX);
MatrixTXabs=abs(MatrixTXFFT).^2/T;
PSDTX=mean(MatrixTXabs');

figure; freq=linspace(-fs/2,fs/2,N); % frequency axis


plot(freq,10*log10(fftshift(PSDTX))); grid on; title('PSD of TX Signal');
% axis([-fs/2 fs/2 25 45]);
Channel (Noise is added)

noise0=randn(1,length(SignalTX)); % generating channel noise

for index2=1:length(SNRvec)
SNR=SNRvec(index2);
Pn=Px/SNR; % calculation of noise power
noise=sqrt(Pn)*noise0;
SignalRX=SignalTX+noise; % adding the noise to the signal

for index=1:length(Bvec);

B=Bvec(index);
SignalRXF = RCfilter(Ts,B,SignalRX); % signal received and filtered

Eye diagram at the output of the channel


eyediagram(SignalRX,3*Ns,3*Ns); % plotting eye diagram

Eye diagram at the filtered signal


eyediagram(SignalRXF,3*Ns,3*Ns); % plotting eye diagram

% MatrixTX=reshape(SignalRX,N,M);
% MatrixTXFFT=fft(MatrixTX);
% MatrixTXabs=abs(MatrixTXFFT).^2/T;
% PSDTX=mean(MatrixTXabs');
%
% figure; freq=linspace(-fs/2,fs/2,N); % frequency axis
% plot(freq,10*log10(fftshift(PSDTX))); grid on; title('PSD of RX Signal');
% axis([-fs/2 fs/2 25 45]);
No=Ns-1; % sampling instant
Samples=SignalRXF(No:Ns:end);
BitsRX=(sign(Samples)+1)/2;
Nerrors=length(find((BitsRX-BitsTX)~=0));
Pe(index2,index)=Nerrors/length(BitsTX);

end
end

plot BER vs. RC Filter Bandwidth

figure;
hold on;
colors = ['-r','-g','-b']; % Color for each SNR line
for index2 = 1:length(SNRvec)
plot(Bvec, Pe(index2, :),colors(index2),'LineWidth', 2);
end
title('BER vs RC Filter BandWidth');
grid on;
legend('-2dB','0dB','2dB');

Published with MATLAB® R2024a

You might also like