Upload
adiseshumidde
View
35
Download
0
Embed Size (px)
DESCRIPTION
communication
Citation preview
Advance Communications Lab Manual 1
M.Tech DECS II Sem Dept. of ECE
1. Measurement of Bit Error Rate using Binary Data
n=23;
k=12;
dmin=7;
ebno=1:10;
ber_block=bercoding(ebno,'block','hard',n,k,dmin);
berfit(ebno,ber_block)
ylabel('bit error probability');
title('ber vs eb/no');
RESULT:
Advance Communications Lab Manual 2
M.Tech DECS II Sem Dept. of ECE
2. Verification of minimum distance in Hamming Code
m=3;
n=2^m-1;
k=4;
msg=[0 0 0 0; 0 0 0 1; 0 0 1 0; 0 0 1 1; 0 1 0 0; 0 1 0 1; 0 1 1 0; 0 1 1 1];
code1 =encode(msg,n,k,'hamming/binary');
code2 =num2str(code1);
code= bin2dec(code2);
number1= [];
for i=1:8
for j=i+1:8
[number]=biterr(code(i),code(j),7);
number1=[number1 number];
end
end
minidistance = min(number1)
Advance Communications Lab Manual 3
M.Tech DECS II Sem Dept. of ECE
3. Determination of output of convolutional Encoder for a given sequence
%convolution encoder;input=1bit output=2bits with 3 memory elements,code
%rate=1/2.
function[encoded_sequence]=convlenc(message)
message=[ 1 0 1 0 1 1 1 0 0 0 1 1 0 1 1 0 0 ];
enco_mem=[ 0 0 0]; %no.of memory elments=3
encoded_sequence=zeros(1,(length(message))*2);
enco_mem(1,3)=enco_mem(1,2);
enco_mem(1,2)=enco_mem(1,1);
enco_mem(1,1)=message(1,1);
temp=xor(enco_mem(1),enco_mem(2));
O1=xor(temp,enco_mem(3));%gener.polynomial=111
O2=xor(enco_mem(1),enco_mem(3));%gener.polynomial=101
encoded_sequence(1,1)=O1;
encoded_sequence(1,2)=O2;
msg_len=length(message);
c=3;
for i=2:msg_len
enco_mem(1,3)=enco_mem(1,2);
enco_mem(1,2)=enco_mem(1,1);
if(i
Advance Communications Lab Manual 4
M.Tech DECS II Sem Dept. of ECE
RESULT:
ans =
Columns 1 through 17
1 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 1
Columns 18 through 34
1 0 0 1 1 0 1 0 1 0 0 0 1 0 1 1 1
ans =
Columns 1 through 17
1 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 1
Columns 18 through 34
1 0 0 1 1 0 1 0 1 0 0 0 1 0 1 1 1
Advance Communications Lab Manual 5
M.Tech DECS II Sem Dept. of ECE
4. Determination of output of convolutional Decoder for a given sequence
tb=2;
t=poly2trellis([3],[7,5]);
encoded_sequence=[ 1 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 1 1 0 1 0 1 1 0 1 1 1 ];
decoded=vitdec(encoded_sequence,t,tb,'trunc','hard')
RESULTS:
decoded =
1 0 1 0 1 1 1 0 0 1 0 0 1 1 1
Advance Communications Lab Manual 6
M.Tech DECS II Sem Dept. of ECE
5. Efficiency of DS Spread Spectrum Technique
%direct sequence spread spectrum
clc
clear all;
%generating the bit pattern with each bit 6 samples long
b=round(rand(1,20));
pattern=[];
for k=1:20
if b(1,k)==0
sig=zeros(1,6);
else
sig=ones(1,6)
end
pattern=[pattern sig];
end
plot(pattern);
axis([-1 130 -0.5 1.5]);
title('\bf\it original bit sequenece');
%generating the psedorandom bit pattern for spreading
spread_sig=round(rand(1,120));
figure,plot(spread_sig);
axis([-1 130 -0.5 1.5]);
title('\bf\it psedorandom bit sequenece');
%xoring the pattern with spread signal
hopped_sig=xor(pattern,spread_sig);
%modulating the hopped signal
dsss_sig=[];
t=[0:100];
fc=0.1;
c1=cos(2*pi*fc*t);
c2=cos(2*pi*fc*t+pi);
for k=1:120
Advance Communications Lab Manual 7
M.Tech DECS II Sem Dept. of ECE
if hopped_sig(1,k)==0;
dsss_sig=[dsss_sig c1]
else
dsss_sig=[dsss_sig c2]
end
end
figure,plot([1:12120],dsss_sig);
axis([-1 12120 -1.5 1.5]);
title('\bf\ it dss signal');
%plotting the fft of dsss signal
figure,plot([1:12120],abs(fft(dsss_sig)));
RESULT:
Advance Communications Lab Manual 8
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 9
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 10
M.Tech DECS II Sem Dept. of ECE
6. Simulation of Frequency Hopping (FH) system
clear all;
s=round(rand(1,20));
signal=[];
carrier=[];
t=[0:10000];
fc=.01;
for k=1:20
if s(1,k)==0
sig= -ones(1,10001);
else
sig=ones(1,10001);
end
c=cos(2*pi*fc*t);
carrier=[carrier c];
signal=[signal sig];
end
subplot(2,1,1);
plot(signal);
axis([-1 200050 -1.5 1.5]);
title('/bf/it original bit sequence');
%BPSK modulation of signal
bpsk_sig=signal.*carrier;
subplot(2,1,2);
plot(bpsk_sig);
axis([-1 200050 -1.5 1.5]);
title('/bf/it BPSK modulated signal');
%FFT plot of BPSK modulated signal
figure, plot([1:200020],abs(fft(bpsk_sig)));
title('/bf/it FFT of BPSKmodulated signal');
%preparation of six carrier frequencies
fc1=.01; fc2=.02; fc3=.03;
Advance Communications Lab Manual 11
M.Tech DECS II Sem Dept. of ECE
fc4=.04; fc5=.05; fc6=.06;
c1=cos(2*pi*fc1*t);c2=cos(2*pi*fc2*t);c3=cos(2*pi*fc3*t);
c4=cos(2*pi*fc4*t);c5=cos(2*pi*fc5*t);c6=cos(2*pi*fc6*t);
%random frequencies hoops to form a spread signal
spread_sig =[];
for n=1:20
c=randint(1,1,[1 6]);
switch(c)
case(1)
spread_sig=[spread_sig c1];
case(2)
spread_sig=[spread_sig c2];
case(3)
spread_sig=[spread_sig c3];
case(4)
spread_sig=[spread_sig c4];
case(5)
spread_sig=[spread_sig c5];
case(6)
spread_sig=[spread_sig c6];
end
end
figure,plot([1:200020],abs(fft(spread_signal)));
freq_hopped_sig=bpsk_sig.*spread_signal;
figure,plot([1:200020],abs(fft(freq_hopped_sig)));
Advance Communications Lab Manual 12
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 13
M.Tech DECS II Sem Dept. of ECE
7. Histogram of a Image
clc;
clear all;
f=imread('cameraman.tif');
figure,imshow(f);
title('Input Image');
h=imhist(f);
h1=h(1:10:256);
horz=1:10:256;
figure,bar(horz,h1);
figure,plot(horz,h1);
title('Histogram Equalized Image');
Z=adapthisteq(f,'cliplimit',0.9,'distribution','uniform');
imview(Z);
b=imhist(f);
figure,imshow(b);
Advance Communications Lab Manual 14
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 15
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 16
M.Tech DECS II Sem Dept. of ECE
8. Verification of various Transforms - FT
RGB=imread('peppers.png');
I=rgb2gray(RGB);
J=fft2(I);
k=ifft2(J);
subplot(2,2,1),imshow(RGB);
title('original image');
subplot(2,2,2),imshow(I);
title('gray scale image');
subplot(2,2,3),imshow(J);
title('DFT');
subplot(2,2,4);imshow(k,[0 255]);
title('IDFT');
RESULT:
Advance Communications Lab Manual 17
M.Tech DECS II Sem Dept. of ECE
9. Verification of various Transforms - DCT
x=imread('lena.png');
subplot(4,1,1);
imshow(x);
title('input image');
%convert rgb to BW image
a=im2bw(x);
subplot(4,1,2);
imshow(a);
title('input BW image')
%convert bw to rgb
b=bw2gray(a);
subplot(4,1,3);
imshow(b);
title('bw to rgb image');
%DCT
d=dct2(a);
subplot(4,1,4);
imshow(d);
title('DCT image');
%Inverse dct
i=idct2(d);
subplot(4,1,5);
h=imshow(i,[0 255]);
title('IDCT image');
Advance Communications Lab Manual 18
M.Tech DECS II Sem Dept. of ECE
10. Detection techniques using derivative operators - Edge
i=imread('coins.png');
imshow(i);
j=edge(i,'sobel');
figure, imshow(j)
k=edge(i,'prewitt');
figure, imshow(k)
l=edge(i,'robert');
figure, imshow(l)
h=edge(i, 'log');
figure, imshow(h)
RESULT:
Advance Communications Lab Manual 19
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 20
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 21
M.Tech DECS II Sem Dept. of ECE
Detection techniques using derivative operators - Point
%point detection%
I=imread('circuit.tif');
H=[1 1 1; 1 -8 1; 1 1 1];
B=imfilter(I,H);
subplot(1,2,1),imshow(I),title('Original image');
subplot(1,2,2),imshow(B),title('Point detection');
Detection techniques using derivative operators - Line
f= imread('coins.png');
imshow(f)
g= edge(f,'horizontal');
h= edge(f,'vertical');
figure, imshow(g)
figure, imshow(h)
k=g+h;
figure,imshow(k)
l=g-h;
figure,imshow(l)
Advance Communications Lab Manual 22
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 23
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 24
M.Tech DECS II Sem Dept. of ECE
11. Implementation of FIR filter
N=60;
R=0.5;
b=firnyquist(N,4,R,0,'nonnegative');
h=firrcos(N,0.25,R,2,'rolloff');
hfvt=fvtool(b,1,h,1);
set(hfvt,'color', [1 1 1]);
legend(hfvt,'FIR NYQUIST DESIGN','FIR RCOS DESIGN');
Advance Communications Lab Manual 25
M.Tech DECS II Sem Dept. of ECE
Advance Communications Lab Manual 26
M.Tech DECS II Sem Dept. of ECE
12. Implementation of IIR filter
clc;
N=10; %UNCONSTRAINED NUMERATOR ORDER
M=10; %UNCONSTRAINED DENOMINATOR ORDER
F=[0 0.4 0.5 1]; %FREQUENCY VECTOR
E=F; %FREQUENCY EDGES
A=[1 1 0 0]; %MAGNITUDE VECTOR
W=[1 1 100 100]; %WEIGHT VECTOR
Nc=12; %CONSTRAINED NUMERATOR ORDER
Mc=12; %CONSTRAINED DENOMINATOR ORDER
R=0.92;
[b,a,err,sos,g]=iirlpnorm(N,M,F,E,A,W);
[bc,ac,errc,sosc,gc]=iirlpnormc(Nc,Mc,F,E,A,W,R);
H(1)=dfilt.df1sos(sos,g);
H(2)=dfilt.df1sos(sosc,gc);
[z,p,k]=zpk(H(2)); %FINDS THE POLES AND ZEROS OF CONSTRAINED FILTER
sqrt(real(p).^2+imag(p).^2) %RADII OF ALL POLES
hfvt=fvtool(H);
legend(hfvt,'IIR unconstrained design','IIR constrained design');
set(hfvt,'color',[1 1 1]);