[go: up one dir, main page]

0% found this document useful (0 votes)
31 views33 pages

Simulated Output Full

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 33

AMPLITUDE SHIFT KEYING

PROGRAM:

Clc;

Clf;

Clear all;

% orthogonal basis function

N=0:1:39

Y1=2*sin(2*pi*2*n/40);

Subplot(3,2,1);

Plot (yl);

Title(‘orthogonal basis function1’);

Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

Y2=n*0;

Subplot(3,2,2);

Plot (y2);

Title(‘orthogonal basis function2’);

Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

grid;

% message bit generation

X=randsrc (1,10, [1 -1]);

Subplot(3,2,3);

Title(‘input bit stream’);

Xlabel(‘time (sec)’);

Ylabel (‘amplitude (v)’);

Stem(x);

axis([1 10 -1.5 1.5]);

grid;

% ask waveform

Z=0;

For i=1:10;

If(x(i)==1);

Z=[z yi];

Else

Z=[z y2);

End;

End;

Subplot (3,2,4);

Plot(z);
Title(‘ask waveform’);

Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

axis ( [0 400 -2.5 2.5]);

% decoded signal

K=1;

For i=1:401;

B(i)=z (i)*y1(k);

K=k+1;

If(k>40)

K=1;

End;

End;

A=0; r=1;g=1;m=40;

for j=1:10;

for i=g:m-1;

a=a+b(i);

end;

if(a>0)

p(r)=1;

else

p(r) =-1;

end;

a=0;r=r+l;g=g+40;m=m+40;

end;

subplot(3,2,5);

stem(p);

title('decoded signal');

xlabel('time (sec)');

ylabel('amplitude (v)');

axis ([1 10 -1.5 1.5]);

grid;
FREQUENCY SHIFT KEYING

PROGRAM:

Clc;

Clf;

Clear all;

% orthogonal basis function

N=0:1:39

Yl=2* sin(2*pi*2*n/40);

Subplot(3,2,1);

Plot(yl);

Title(‘orthogonal basis function1’);

Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

Y2=2* sin(2*pi* 2* n/80);

Subplot(3,2,2);

Plot (y2);

Title(‘orthogonal basis function2’);

Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

% message bit generation

X=randsrc (1,10, [1 -1]);

Subplot(3,2,3);

Title(‘input bit stream’);

Xlabel(‘time (sec)’);

Ylabel (‘amplitude (v)’);

Stem (x);

Axis ([1 10 -1.5 1.5]);

Grid;

% fsk waveform

Z=0;

For i=1:10;

If(x(i) ==1);

Z=(z y1);

Else

Z=(z y2);

End;

End;

Subplot(3,2,4);

Plot(z);

Title(‘fsk waveform’);
Xlabel(‘time (sec)’);

Ylabel(‘amplitude (v)’);

Axis ( [0 400 -2.5 2.5]);

% decoded signal

K=1;

For i=1:401;

B(i)=z (i)*y1(k);

K=k+1;

If (k>40)

K=1;

End;

End;

A=0;r=1;971;m=40;

For j=1:10;

For i=g:m-1;

a=a+b(i);

end;

if (a>0)

p(r)=1;

else

p(r)=-1;

end;

a=0;r=r+l;g=g+40; m=m+40;

end;

subplot(3,2,5);

stem(p);

title('decoded signal ) ;

xlabel('time (sec)');

ylabel ('amplitude (v)');

axis ([1 10 -1.5 1.5]);

grid;
n‹thngenal basis function1
2

0 t£I 20 30 40
time(sec) time(sec)
fsk waveform
i 2

2 4 6 6 10
time(sec)
decoded signal

10 ,
SIMULATION OF BPSK

PROGRAM:

Clc;

Clear all;

B=input(‘enter the bit stream’);

N=length(b);

T=0:0.01:n;

X=1:1n+1)*100;

For i=1:n

If(b(i)==0)

u(i)=-1;

Else

u(i)=1;

End

For j=i:0.1:1+1

bw(x(i*100i+1)*100))=

(i); End

End

Bw=bw(100:end);

Sint=sin(2*pi*t);

“st=bw.*sint;

Subplot(3,1,1);

Plot(t,bw);

Xlabel(‘n-’);

Ylabel(‘amplitude ’);

Title(‘input bit stream’);

Grid on;

Axis([O n -2 +2]);

Subplot(3,1,2);

Plot(t, sint);

Xlabel(‘time-’);

Ylabel(‘amplitude

’);Title(‘carrier

wave’); Grid on;

Axis([On-2 +2]);

Subplot(3,1,3);

Plot(t,st);

Xlabel(‘time’);

Ylabel(‘amplitude –’

Title(‘bpsk wave’);

Grid on;

Axis([On-2 +2]);
SIMULATION GF BPSK
DIFFERENTIAL PHASE SHIFT KEYING

PROGRAM:

close all;

clear all;

clc;

B=[1 0 0 1 0 0 1 1 ];

B not=~B;

count=0;

Dk=[];

for i=1:1:length (B);

if (B(i)==0)

count=count+1;

if (count>1)

Dk (i)=0;

else

Dk (i)=1;

end

else

if (B(i)==1)

Dk (i)=1;

count=0;

end

end

end

Dk_ not=~Dk;

result=[];

result1=[];

result2=[];

resulti=Dk& B;

result2=Dk_not&B_not;

result=xor (resulti, result2);

final=[];

for i=1:1: length (result+1)

final (1)=1;

final (i+1)=result(i);

end

main final=-final;

fs=1000;

n=0:1:39;

y1=2*sin (2*pi*2*n/40);
y2=2* sin(2*-pi*24n/40);

z=0;

for i=(1:1:length (main final))

if (main final (i) ==1)

z=[z y1];

else

z=[z y2];

end

end

Plot(z);

Xlabel(‘time (t)’);

Ylabel(‘amplitude’);

Title (‘DPSK[num2str (main final)]’);

Grid on
OUTPUT: DIFFERENTIAL PHASE SHIFT KEYING
PHASE SHIFT KEYING

PROGARM:

clc;

clf;

clear all;

n=0:1:39;

yl=2*sin (2*pi*2*n/40);

subplot(3,2,1);

plot(yl);

title('orthogonal basic functioni');

xlabel('time (sec)');

ylabel ('amp (v)');

y2=2*sin (2*pi*2*n/40);

subplot(3,2,2);

plot(y2);

title('orthogonal basis function2');

xlabel('time (sec)');

ylabel ('amp (v)');

x=randsrc (1,10, [1 -1]);

subplot(3,2,3);

title('input bit stream');

xlabel('time (sec) ');

ylabel('amp (v)');

stem (x);

axis ([1 10 -1.5 1.5]);

grid;

z=0;

for i=1:10;

if (x (i)==1);

z=[z y1];

else

z=[z y2];

end;

end;

subplot(3,2, 4);

plot (z);

title('psk waveform');

xlabel('time (sec)');

ylabel ('amp (v)');

axis ( [0 400 -2.5 2.5]);


k=1;

for i=1:401;

b(i)=z (i) *y1 (k);

k=k+1;

if (k>40)

k=1;

end;

end;

a=0;r=1;g=1;m=40;

for j=1:10;

for i=g:m-1;

a=a+b (i);

end;

if (a>0)

p(r)=1;

else

p(r)=-1;

end;

a=0;r=r+1;g=g+40;m=m+40;

end;

subplot(3,2,5);

stem (p);

title('decoded signal')

xlabel('time (sec)');

ylabel ('amp (v)');

axis ([1 10 -1.5 1.5]);

grid;
OUTPUT: SIMULATION OF PSK
SIGNAL CONSTELLATION OF QPSK

PROGRAM:

Clc;

Clear all;

Close all;

Data=[0010011 1];

Figure(1)

Stem(data,’linewidth’,3);

Grid on;

Title(‘information before transmitting’);

Axis([0 11 0 1.5]);

Data_NZR=2*data-1;

S_p_data=reshape(data_NZR, 2,length(data)/2);

Br=10^6;

F=br;

T=1/br;

T=T/99:T/99:T;

Y=[];

Y_in=[];

Y_qd=[];

D=zeros(1,length(data)/2);

For i=1:length(data)/2

P=data(2*i);

Imp=data(2*i-1);

Y1=s_p_data(1,1)* cos(2*pi*f*t);

Y2=s_p_data(2*i)* sin(2*pi*f*t);

Y_in=[y_in y1];

Y_qd=[y_qd y2];

Y=[y y1+y2];

If(imp==0)&&(p==0)

D(i)=exp(j*pi/4);

End

If(imp==1)&&(p==0)

D(i)=exp(j*3*pi/4);

End

If(imp==1)&&(p==1)

D(i)=expl*5*pi/4);

End

If(imp==0)&&(p==1)

D(i)=exp(j*7* pi/4);
End

End

Tx_sig=y

qpsk=d

tt=T/99:T/99T*length(data))/2;

Figure(2)

Subplot(3,1,1);

Plot(tt,y_in, ‘linewidth’,3);

Grid on;

Title(‘waveform for inphase component in qpsk modulation’);

Xlabel(‘time(sec)’);

Ylabel(‘amplitude (volto)’);

Subplot(3,1,2);

Plot(tt,y_qd,’linewidth’,3);

Grid on;

Title(‘waveform for quadrature component in qpsk modulation’);

Xlabel(‘time(sec)’);

Ylabel(‘amplitude(volto)’);

Subplot(3,1,3);

Plot(tt, Tx_sig,’g’, ‘linewidth’,3);

Grid on;

Title(‘qpsk modulated signal’);

Xlabel(‘time(sec)’);

Ylabel(‘amplitude(volto)’);

Figure(3)

Plot(d,’o’);

Axis([-22-22]);

Grid on;

Xlabel(‘real’);

Ylabel(“img”);

Title(‘qpsk constellation’);
OL ITPLIT :

on

x 10 6
SIGNAL CO NSTELLATI ON OF QPSK
OBSERVATION OF SIGNAL CONSTELLATION OF QPM

PROGRAM:

Clc;

Clear all;

N=32;

M=4;

No_of_rows=n/2;

No_of_bits_in_symbol=2;

Data in=randint(1,n);

Len_data_in=length (data_in);

Data_instp=reshape (data_in, no_of_rows, no_of_bits_in_symbol);

Size (data_instp);

Data_in_sym=bi2 de (data_instp);

Stem (data_in_sym);

Title (‘random symbol’);

Xlabel (‘symbol index’);

Ylabel (‘integer value’);

Mod_data=qammod (data_in_sym,M);

Scatterplot (mod data);


OBSERVATION OF SIGNAL CON.STELLA TION OF CtAM

OUTPUT:
ERROR CONTROL CODING SCHEMES

PROGRAM:

clc;

clear all;

close all. ;

g=input('enter the generator matrix:');

disp (g);

disp('the order of linear block code for generation matrix is');

[n, k]=size (transpose (g));

disp('n=b');

disp (n);

disp('k=3');

disp (k);

for i=1:24k;

for j=k:-1:1;

if rem (i-1,2^(-j+k+1)) >=2^(-j+k);

u(i, j)=1;

else

u(i, j)=0;

end;

end;

end;

disp('the possible code words are:');

c=rem (u*g, 2);

disp('c=');

disp('the minimum hamming distance dmin for given block code is=');

d_min=min (sum ( (c(2:2^k, :))'));

disp('d_min=');

disp (d_min);

r=input('enter the recieved code word: ');

disp('r=');

disp (r);

p=[g(:,n-k+1:n)];

h=[transpose (p), eye (n-k)];

disp('hamming code');

ht=transpose (h);

disp('ht=');

disp (ht);

disp('syndrome of a given codeword is');

s=rem (r*ht, 2);


disp('s=');

disp(s);

for i=1:1: size (ht);

if (ht(1, 1:3) ==s);

r(i)=1-r(i);102;

break;

end;

end;

disp('the error is in bit');

disp('i=');

disp (i);

disp('the corrected codeword ');

disp('r=');

disp (r);
OUTPUT:

Enter the green matrix:[1 0 0 1 0 1;0 1 0 1 1;0 0 1 1 1 1]

1 0 0 1 0 1

0 1 0 1 1 0
0 0 1 1 1 1

The order of linear block code for generation matyrix is

N=b

K=3

The possible code words are:

C=

The minimum haming distance dmin for given block code is=

D_min=3

Enter the received code word:[1 1 1 1 0 1]

R=

111101

Hamming code

Ht=

1 0 1

1 1 0

1 1 1

1 0 0

0 1 0

0 0 1

Syndrome of a given codeword is

S=

001

The error is in bit

I=

The corrected codeword

R=

111100

>>
CYCLIC BLOCK CODES

PROGRAM:

Clc;

Clear all;

N=7;

K=4;

Disp(‘message bit’);

Msg=randint(2,k, [0,1]);

Disp (msg);

Disp(‘cyclic polynomial’);

Pol=cyclpoly(n,k, ‘min’);

Disp (pol);

Disp(‘code vector’);

Code=encode (msg, n,k, ‘cycliccodes’ pol);

Disp (code);

Disp(‘error pattern generation’);

Erranderr (2,n,(1,0;0.8 0.2));

Disp € ;

Disp(‘received matrix’);

R=rem (plus (code, e), 2);

Disp ® ;

Disp(‘decoded message bit’);

Newmsg=decode (r, n,k,’cyclic codes’);

Disp (newmsg);
CYCLIC BLOCK CODES

OUTPUT:

Message bit:

1 1 1 0

0 0 10

Cyclic polynomial

1011

Code vector

1 0 0 1 1 1 0

1 1 0 0 0 1 0

Error pattern generation

0000000

0 0 0 0 0 00

Received matrix

100111 0

1 1 0 0 0 1 0

Decoded message bit

1110

0010
SIMULATION OF COLTVOLUTION SCHEMES

PROGRAM:

Clc;

M=input(‘enter the input sequence ‘);

1=input(‘enter constraint length’);

Gl=input(‘enter impulse response’);

G2=input(‘enter impulse ‘);

T=poly2trellis ([1], [g1 92]);

Disp(t);

C=convenc (m, t);

Disp ©;

%decoding

Opmode=’trunc’;

Detype=’hard’ ;

R=input(‘enter received/code’);

Decorvitdec (r, t, 1, opraode, detype);

Disp (deco);

Code
SIMULATION OF CONVOLUTION SCHEMES

OUTPUT:

Enter the input sequence [1 0 1 1 0]

Enter constraint length 3

Enter impulse response 5

Enter impulse 7

numInputSymbols:2

numOutputSymbols:4

numStates:[4x2 double]

outputs:[4x2 double]

1101001010

Enter received code [1 1 0 1 0 0 1 0 1 0]

10110

>>
COMMUNICTION LINKED SIMULATION

PROGRAM:

clc;

clear all;

close all;

A=5;

fa=50;T=1/fa;

t=0: T/1000:2*T;

ya=3*sin (2*pi*fa*t);

figure (1);

subplot(3,1,1);

plot(t, ya);

title('modulating signal');

xlabel('time (sec)');

ylabel('amp (v)');

A=5;

fc=2000;

yc=A*sin (2*pi*fc*t);

figure (1);

subplot(3,1,2);

plot(t, yc);

title('carrier signal');

xlabel('time (sec)');

ylabel ('amp (v)');

ym= (A+ya). *sin (2*pi*fc*t);

figure (1);

subplot(3,1,3);

plot(t, ym);

title('modulating signal');

xlabel('time (sec)');

ylabel('amp (v)');

ym=tA+ya).*sin (2*pi*fc*t);

figure (2);

subplot (4,1,1);

plot(t, ym);

title('received signal');

xlabel('time (sec)');

ylabel('amp (v)');

A=5;

fc=2000;
yo=A* sin(2*pi*fct);

figure (2);

subplot (4,1,2)

plot(t,yc);

title('carrier signal');

xlabel('time (sec)');

ylabel('amp (v)');

ymm=ym. *sin (2*pi*fc*t);

figure (2);

subplot(4,1,3);

plot(t, ymm);

title ('recievedsignalafter multiplication of carrier signal');

xlabel('time (sec)');

ylabel('amp (v)');

wc=200/50000;

[a b]=butter (2,wc, 'low');

sig=filter (a, b, ymm) ;

figure (2);

subplot(4,1, 4);

plot(t, 2*sig-5);

title('am demodulated signal');

xlabel('time (sec)');

ylabel ('amp (v)');


COMMUNICATION LINKED SIMULATION
OUTPUT:

OOS
EQUALIZATION

PROGRAM:

clear all;

close all;

hold off ;

sysorder=5;

N=200;

inp=randn (N, 1);

n=randn (N, 1);

[b, a]=butter (2,0.25);

Gz=tf (b, a,-1);

sh=ldiv (b, a, sysorder);

h=[0.0976;

0.2873;

0.3360;

0.2210;

0.0964;] ;

y=lsim (Gz, inp);

n=n*std (y) / (10*std (n));

d=y+n;

totallength=size (d, 1);

N=60;

wrzeros (sysorder, 1);

for n=sysorder:N

u=inp (n:-1:n-sysorder+1);

y (n)=w'*u;

e (n)=d (n) -y (n);

if n<20

mu=0.32;

else

mu=0.15;

end

w=w+mu*u*e (n) ;

end

for n=N+1: totallength

u=inp (n:-1:n-sysorder+1));

y (n)=w'*u;

e (n)=d (n) -y (n) ;

end

hold on
plot(d) ;

plot(y, 'r');

title('system output').;

xlabel('samples');

ylabel('true and estimated output');

figure

semilogy ( (abs (e))) ;

title ('error curve');

xlabel('error vàlue');

figure

plot(h, 'k+');

hold on

plot(w, 'r*');

legend('actual weights', 'estimated weights')

title('comparison of the actual weights and estimated weights');

axis ( [0 6 0.05 0.35])

You might also like