NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

1) E of BPSK
clear ; %Clear all variables
close all; % Close all figures
num_bit=1e6; %Number of bits or symbols
EbNodB=0:1:10; %Range of EbNo in dB
for i=1:length(EbNodB);
s=2*(round(rand(1,num_bit))-0.5); %Random symbol generation
w=(1/sqrt(2*10^(EbNodB(i)/10)))*randn(1,num_bit); %Random noise
generation
r=s+w; %Received signal
s_est=sign(r); %Demodulation
sim_BER(i)=(num_bit-sum(s==s_est))/num_bit;%BER calculation
end
the_Ber =0.5*erfc(sqrt(10.^(EbNodB/10))); % theoretical BER calculation
semilogy(EbNodB, sim_BER,'
-
'); %Plotting simulated values
hold on
semilogy(EbNodB,the_Ber,'ko'); %Plotting theoretical values
title('Bit error probability curve for BPSK modulation');
legend('Simulation','Theoretical');
xlabel('EbNo(dB)')
ylabel('BER')
grid on


2) Qpsk

clear ; %Clear all variables
close all; %Close all figures
num_bit=1e6;
EbNodB=0:1:10;
EbNo=10.^(EbNodB/10);
for n=1:length(EbNodB)
si=2*(round(rand(1,num_bit))-0.5); %In-phase symbol generation
sq=2*(round(rand(1,num_bit))-0.5); %Quadrature symbol generation
s=si+1j*sq; %Adding the two parallel symbol streams
w=(1/sqrt(2*EbNo(n)))*(randn(1,num_bit)+1j*randn(1,num_bit)); %Random
noise generation
r=s+w; %Received signal
si_=sign(real(r)); %In-phase demodulation
sq_=sign(imag(r)); %Quadrature demodulation
ber1=(num_bit-sum(si==si_))/num_bit; %In-phase BER calculation
ber2=(num_bit-sum(sq==sq_))/num_bit; %Quadrature BER calculation
sim_BER(n)=mean([ber1 ber2]); %Overall BER
end
the_Ber = 0.5*erfc(sqrt(10.^(EbNodB/10))); % theoretical calculation of BER
semilogy(EbNodB, sim_BER,'
-
'); %Plotting simulated values
hold on
semilogy(EbNodB,the_Ber,'ko'); %Plotting theoretical values
title('BER curve for QPSK modulation');
legend('Simulation','Theoretical');
xlabel('EbNo(dB)')
ylabel('BER')
grid on

3)pulse shaping matched filter

close all;
clear;
rolloff = 0.4; % Rolloff factor
span = 10; % Filter span in symbols
sps = 8; % Samples per symbol
M = 4; % Modulation order
k = log2(M); % Bits per symbol
% Create a vector of bipolar data.
BP_Data = 2*randi([0 1],10, 1) - 1;
% Generate the square-root, raised cosine filter coefficients.
rctFilt = rcosdesign(rolloff, span, sps,'sqrt');
% rctFilt = rcosdesign(rolloff, span, sps,'normal');
fvtool(rctFilt,'impulse')
% Upsample and filter the data for pulse shaping.
UP_s = upfirdn(BP_Data, rctFilt, sps,1);
% Using the number of bits per symbol (k) and the number of samples per
symbol (sps),
% convert the ratio of energy per bit to noise power spectral density (EbNo)
% to an SNR value for use by the awgn function.
EbNo = 100;
snr = EbNo + 10*log10(k) - 10*log10(sps);
% filtlen = 10; % Filter length in symbols
rxSignal = awgn(UP_s,snr);% filtering the signal through an AWGN channel.
% Add noise.
rxSignal = rxSignal + randn(size(rxSignal))*.01;
rxFiltSignal = upfirdn(rxSignal,rctFilt,1,sps); % Down sample and filter
rxFiltSignal = rxFiltSignal(span + 1:end - span); % Account for delay
% Plotting the function
figure;
stem(BP_Data,'filled')
hold on
plot(rxFiltSignal,'r')
xlabel('Time'); ylabel('Amplitude');
legend('Transmitted Data','Received Data')
figure;
plot(rxSignal)
legend('Filtered signal through AWGN')



4) eye diagram

close all
clear;
rolloff = 0.4; % Rolloff factor
span = 10; % Filter span in symbols
sps = 7; % Samples per symbol
M = 16; % Modulation order
k = log2(M); % Bits per symbol
% Generate the square-root, raised cosine filter coefficients.
rctFilt=rcosdesign(rolloff, span, sps,'normal');
fvtool(rctFilt,'Analysis','impulse')
% Create a vector of bipolar data.
BP_Data = 2*randi([0 1], 50, 1) - 1;
% Upsample and filter the data for pulse shaping.
UP_s = upfirdn(BP_Data, rctFilt, sps,1);
% Using the number of bits per symbol (k)
% and the number of samples per symbol (sps),
% convert the ratio of energy per bit to noise power spectral density (EbNo)
% to an SNR value for use by the awgn function.
EbNo = 100;
snr = EbNo + 10*log10(k) - 10*log10(sps);
filtlen = 10; % Filter length in symbols
rxSignal = awgn(UP_s,snr,'measured');% filtering the signal through an
AWGN channel.
% Add noise.
rxSignal = rxSignal + randn(size(rxSignal))*.01;
rxFiltSignal = upfirdn(rxSignal,rctFilt,1,sps);% Downsample and filter
rxFiltSignal = rxFiltSignal(filtlen + 1:end - filtlen); % Account for
delay
% Plotting the function
figure;
stem(BP_Data,'filled')
hold on
plot(rxFiltSignal,'r')
xlabel('Time');
ylabel('Amplitude');
legend('Transmitted Data', 'Received Data')
figure;
plot(rxSignal)
legend('Filtered signal through AWGN')
eyediagram(BP_Data,2);legend('Transmitted signal')
eyediagram(rxSignal,2);legend('Recieved signal')
eyediagram(rxFiltSignal,2);legend('Filtered signal')


5) pcm

clc;
close all;
clear ;
n=input('Enter for n-bit PCM system : '); %Encoded Bit Length
n1=input('Enter Sampling Frequency : '); %Sampling Frequency
% Here we plot the Analog Signal and its sampled form
Vmax = 1;
x = 0:pi/n1:2*pi; %Construction of Signal
ActualSignl=Vmax*sin(x); %Actual input
subplot(3,1,1);
plot(ActualSignl);
title('Analog Signal');
subplot(3,1,2); %Sampled Version
stem(ActualSignl);
title('Sampled Sinal');
% Now perform the Quantization Process
L = 2^n; %Number of Quantisation Levels %
Vmin=-Vmax; %Since the Signal is sine
StepSize=(Vmax-Vmin)/L; % Diference between each quantisation level
QuantizationLevels=Vmin:StepSize:Vmax; % Quantisation Levels - For
comparison
codebook=Vmin-StepSize/2):StepSize:Vmax+(StepSize/2); %
Quantisation Values - As Final Output of qunatiz
[ind,q]=quantiz(ActualSignl,QuantizationLevels,codebook);
% Quantization process
% MATLAB gives indexing from 1 to N.But we need indexing from 0, to
convert it into binary codebook
NonZeroInd = find(ind ~= 0);
ind(NonZeroInd) = ind(NonZeroInd) - 1;
%This is for correction, as signal values cannot go beyond Vmin
%But quantiz may suggest it, since it return the Values lower than Actual
Signal Value
BelowVminInd = find(q == Vmin-(StepSize/2));
q(BelowVminInd) = Vmin+(StepSize/2);
% Display the Quantize values
subplot(3,1,3); stem(q); grid on;
title('Quantized Signal');
% Having Quantised the values, we perform the Encoding Process
TransmittedSig = de2bi(ind,'left-msb'); % Encode the Quantisation Level
% Reshaping the signal
SerialCode =
reshape(TransmittedSig',[1,size(TransmittedSig,1)*size(TransmittedSi g,2)]);
figure
% Display the SerialCode Bit Stream
subplot(2,1,1);
grid on; stairs(SerialCode);
axis([0 50 -2 3]);
title('Transmitted Signal');
% Now we perform the Demodulation Of PCM signal
% Again Convert the SerialCode into Frames of 1 Byte
RecievedCode=reshape(SerialCode,n,length(SerialCode)/n);
index = bi2de(RecievedCode','left-msb'); %Binary to Decimal
Conversion
q = (StepSize*index); %Convert into Voltage Values
q = q + (Vmin+(StepSize/2));
% Above step gives a DC shfted version of Actual siganl
%Thus it is necessary to bring it to zero level
subplot(2,1,2);
grid on;
plot(q); % Plot Demodulated signal
title('Demodulated Signal');
% SNR vs no of bits per symbol
for Nvar=1:10 %running for 10 times
Lvar=2^Nvar; % level calculation
StepSizevar=(Vmax-Vmin)/Lvar; % step sizecalculation
QLevelvar=Vmin:StepSizevar:Vmax; % level are between vmin and
vmax with difference of del
code=Vmin-(StepSizevar/2):StepSizevar:Vmax+(StepSizevar/2);
%Contaion Quantized valuses [ind,x]=quantiz(ActualSignl,QLevelvar,code);
% Quantization process
a(Nvar)=snr(x,ActualSignl); % SNR calculation
end
figure
plot(a); % plotting signal to noise ratio vs no of bit
title('SNR versus number of bits per symbol');
ylabel('SNR in dB--->');
xlabel('No. of bits per symbol--->')
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.