Pages

Showing posts with label Digital Modulation Technique. Show all posts
Showing posts with label Digital Modulation Technique. Show all posts

Saturday, 27 April 2013

Pulse Amplitude Modulation (Matlab 2012a)

Program:

clc;
clear all;
a = input('Enter the amplitude = ');
f = input('Enter the frequency = ');
n = input('Enter the N value = ');
t = 0:0.1:n;
x1 = stem(-t/3);
x2 = sin(2*pi*f*t);
y = x1.*x2;
subplot(3,1,1);
stem(x1);
title('Impulse Signal');
ylabel('Amplitude ---->');
xlabel('n ---->');
grid on;
subplot(3,1,2)
plot(t,x2);
title('Sine Wave');
xlabel('Time ----->');
ylabel('Amplitude ----->');
grid on;
subplot(3,1,3)
stem(t,y);
title('Pulse Modulated Wave');
xlabel('Time ----->');
ylabel('Amplitude ----->');
grid on;


Output:

Enter the amplitude = 5
Enter the frequency = 1
Enter the N value = 2 

 
Waveform:



Sunday, 3 March 2013

Natural Sampling (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.001:1;
fc = input('Enter the frequency of carrier signal (square) = ');
fm = input('Enter the frequency of message signal (sine) = ');
a = input('Enter the amplitude of message signal = ');
vc = square(2*pi*fc*t);
vm = a.*sin(2*pi*fm*t);
n = length(vc);
for i = 1:n
    if (vc(i)<=0)
        vc(i) = 0;
    else
        vc(i) = 1;
    end
end

y = vc.*vm;
subplot(3,1,1);
plot(t,vm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Message Signal');
axis([0 1 -a-2 a+2]);
grid on;
subplot(3,1,2);
plot(t,vc);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Carrier Signal');
axis([0 1 0 2]);
grid on;
subplot(3,1,3);
plot(t,y);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Natural Sampled Signal');
axis([0 1 -a-2 a+2]);
grid on;


Output:

Enter the frequency of carrier signal (square) = 20
Enter the frequency of message signal (sine) = 2
Enter the amplitude of message signal = 5


Waveform:

Thursday, 28 February 2013

CDMA (Matlab 2012a)

Program:

clc;
clear all;
code_length = input('Enter Code Length = ');
data_stream = input('Enter Data Bit Stream = ');
%Generating Walsh Code
code = [-1 -1; -1 +1];   
[r1 c1] = size(code);
disp('Walsh code generated = ');
while r1<code_length
    code = [code,code;code,-1*code];
    [r1 c1] = size(code);
    disp(code);
end
code_length = length(code); %length (number of bits) of code
Y = size(data_stream);             
N = Y(1); %number of unique senders / bit streams
I = Y(2); %number of bits per stream
T = []; %sum of all transmitted and encoded data on channel
data_received = []; %vector of reconstructed bits at receiver
%show data bits and codes
disp('Data bit stream to be transmitted = '),disp(data_stream);
disp('Walsh codes used for transmission = '),disp(code);
%encode bits and transmit
G = zeros(I,code_length);
for n = 1:N
    Z = zeros(I,code_length);
    for i = 1:I
        for m = 1:code_length
            Z(i,m) = [data_stream(n,i)*code(n,m)];       
        end
    end
    G = G + Z;
end
%show channel traffic
for i = 1:I
    T = [ T G(i,:) ];
end
disp('Resulting traffic on the channel = '),disp(T);
%decode and reconstruct
for n = 1:N
    tot = zeros(1,I);
    R   = zeros(I,code_length);
    for i = 1:I
        for m = 1:code_length
            R(i,m) = G(i,m) * code (n,m);
            tot(i) = tot(i) + R (i,m);
         end
    end
    data_received = [data_received ; tot / code_length];
end
disp('Reconstructed data at the receiver = '),disp(data_received);


Output:

Enter Code Length = 4
Enter Data Bit Stream = [ 1 -1  1 -1  1  1 -1 -1 ;
        -1 -1  1  1  1 -1 -1  1 ;
         1  1 -1 -1 -1  1  1 -1 ;
         1  1  1  1 -1 -1 -1 -1 ];


Walsh code generated =
    -1    -1    -1    -1
    -1     1    -1     1
    -1    -1     1     1
    -1     1     1    -1

Data bit stream to be transmitted =
     1    -1     1    -1     1     1    -1    -1
    -1    -1     1     1     1    -1    -1     1
     1     1    -1    -1    -1     1     1    -1
     1     1     1     1    -1    -1    -1    -1

Walsh codes used for transmission =
    -1    -1    -1    -1
    -1     1    -1     1
    -1    -1     1     1
    -1     1     1    -1

Resulting traffic on the channel =
  Columns 1 through 19

    -2    -2     2    -2     0     0     4     0    -2     2    -2    -2     0     4     0     0     0     0    -4

  Columns 20 through 32

     0     0    -4     0     0     2    -2     2     2     2     2    -2     2

Reconstructed data at the receiver =
     1    -1     1    -1     1     1    -1    -1
    -1    -1     1     1     1    -1    -1     1
     1     1    -1    -1    -1     1     1    -1
     1     1     1     1    -1    -1    -1    -1

Sunday, 18 November 2012

Error Probability Curve of M-ary PSK (Matlab 2012a)

Program:

clc;
clear all;
n = input('Enter the number of values to be compared = ');
colour = ['k','r','g','b','y'];
nsample = 1;
m = 4;
for i = 1:n
    eb_db = 0:0.0001:25;
    k = log2(m);
    es_db = eb_db + 10*log(k) + 10*log(nsample);
    es = db2mag(es_db);
    p = 2*qfunc(sqrt(2*es).*sin(pi/m));
    semilogy(eb_db,p,colour(k));
    hold on;
    m = m*2;
end
xlabel('SNR ----->');
ylabel('Probability of Error ----->');
title('Error Probability Curve of M ary PSK');
grid on;
legend('m = 4','m = 8','m = 16','m = 32');


Output:

Enter the number of values to be compared = 4

Output Graph:


Error Probability Curve of M-ary QAM (Matlab 2012a)

Program:

clc;
clear all;
n = input('Enter the number of values to be compared = ');
colour = ['k','r','g','b','y'];
nsample = 1;
m = 4;
for i = 1:n
    eb_db = 0:0.0001:25;
    k = log2(m);
    es_db = eb_db + 10*log(k) + 10*log(nsample);
    es = db2mag(es_db);
    p = 4*qfunc(sqrt(3*es/(m-1)));
    semilogy(eb_db,p,colour(k));
    hold on;
    m = m*2;
end
xlabel('SNR ----->');
ylabel('Probability of Error ----->');
title('Error Probability Curve of M ary QAM');
grid on;
legend('m = 4','m = 8','m = 16','m = 32');


Output:

Enter the number of values to be compared = 4

Output Graph:


Friday, 16 November 2012

Pulse Code Modulation (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.0005:20;
partition = -1:0.1:1;
codebook = -1:0.1:1.1;
x = sin(t);
[index,quants] = quantiz(x,partition,codebook);
subplot(3,1,1);
plot(t,x);
title('Message Signal');
xlabel('Time(s) ---->')
ylabel('Amplitude(V) ---->')
subplot(3,1,2);
plot(t,quants);
title('Quantized Signal');
xlabel('Time(s) ---->')
ylabel('Amplitude(V) ---->')
y = uencode(quants,3);
subplot(3,1,3);
plot(t,y);
title('PCM Signal');
xlabel('Time(s) ---->');
ylabel('Amplitude(V) ---->')




Output Waveforms: 

Wednesday, 14 November 2012

Pulse Width Modulation (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.001:1;
fc = input('Enter the frequency of carrier signal (sawtooth) = ');
fm = input('Enter the frequency of message signal (sine) = ');
a = input('Enter the amplitude of carrier signal = ');
b = input('Enter the amplitude of message signal(should be < Carrier) = ');
vc = a.*sawtooth(2*pi*fc*t);
vm = b.*sin(2*pi*fm*t);

n = length(vc);
for i = 1:n
    if (vm(i)>=vc(i))
        pwm(i) = 1;
    else
        pwm(i) = 0;
    end
end
subplot(3,1,1);
plot(t,vm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Message Signal');
grid on;
subplot(3,1,2);
plot(t,vc);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Carrier Signal');
grid on;
subplot(3,1,3);
plot(t,pwm);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('PWM Signal');
axis([0 1 0 2]);
grid on;


Output:

Enter the frequency of carrier signal (sawtooth) = 10
Enter the frequency of message signal (sine) = 1
Enter the amplitude of carrier signal = 5
Enter the amplitude of message signal(should be < Carrier) = 4 


Output Waveforms:

Tuesday, 13 November 2012

Comparison of M-ary PSK and M-ary QAM (Matlab 2012a)

Program:

 clc;

clear all;
n = input('Enter the number of values to be compared = ');
for i = 1:n;
    m = 2^i;
    r = (3/(m-1))/(2*(sin(pi/m))^2);
    rm = 10*log10(r);
    if(m==4)
        disp('QAM & PSK have comparable performance by = ');
    else
        disp('SNR of QAM is better than PSK by = ');
    end
    disp(rm);
end

Output:


Enter the number of values to be compared = 5

SNR of QAM is better than PSK by =
    1.7609

QAM & PSK have comparable performance by =

   9.6433e-16

SNR of QAM is better than PSK by =

    1.6531

SNR of QAM is better than PSK by =

    4.1953

SNR of QAM is better than PSK by =

    7.0213

Sampling Theorem Proof (Matlab 2012a)

Program:

clc;

clear all;
t = 0:0.001:1;
fm = input('Enter the modulating signal frequency = ');
x = sin(2*pi*fm*t);
subplot(4,2,1);
plot(t,x);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Message Signal');
fs1 = input('Enter Sampling Frequency < Modulating Signal Frequency = ');
fs2 = input('Enter Sampling Frequency = Modulating Signal Frequency = ');
fs3 = input('Enter Sampling Frequency > Modulating Signal Frequency = ');
%Sampling at fs<<2fm
n = 0:1/fs1:1;
x1 = sin(2*pi*fm*n);
subplot(4,2,2);
stem(n,x1);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Undersampled fs<<2fm Signal');
subplot(4,2,3);
plot(n,x1);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Reconstructed Undersampled fs<<2fm Signal');
%Sampling at fs=2fm
n = 0:1/fs2:1;
x2 = sin(2*pi*fm*n);
subplot(4,2,4);
stem(n,x2);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Sampled at Nyquist Rate fs=2fm Signal');
subplot(4,2,5);
plot(n,x2);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Reconstructed Nyquist Rate fs=2fm Signal');
%Sampling at fs>>2fm
n = 0:1/fs3:1;
x3 = sin(2*pi*fm*n);
subplot(4,2,6);
stem(n,x3);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Oversampled fs>>2fm Signal');
subplot(4,2,7);
plot(n,x3);
xlabel('Time ----->');
ylabel('Amplitude ----->');
title('Reconstructed Oversampled fs>>2fm Signal');

Output:


Enter the modulating signal frequency = 15

Enter Sampling Frequency < Modulating Signal Frequency = 10
Enter Sampling Frequency = Modulating Signal Frequency = 30
Enter Sampling Frequency > Modulating Signal Frequency = 500

Output Waveforms:


Friday, 9 November 2012

QPSK (Matlab 2012a)

Program:

clear;
clc;
b = input('Enter the bit stream = ');
n = length(b);
t = 0:0.01:n;
x = 1:1:(n+2)*100;
for i = 1:n
if (b(i) == 0)
u(i) = -1;
else
u(i) = 1;
end
for j = i:0.1:i+1
bw(x(i*100:(i+1)*100)) = u(i);
if (mod(i,2) == 0)
bw_e(x(i*100:(i+1)*100)) = u(i);
bw_e(x((i+1)*100:(i+2)*100)) = u(i);
else
bw_o(x(i*100:(i+1)*100)) = u(i);
bw_o(x((i+1)*100:(i+2)*100)) = u(i);
end
if (mod(n,2)~= 0)
bw_e(x(n*100:(n+1)*100)) = -1;
bw_e(x((n+1)*100:(n+2)*100)) = -1;
end
end
end
bw = bw(100:end);
bw_o = bw_o(100:(n+1)*100);
bw_e = bw_e(200:(n+2)*100);
cost = cos(2*pi*t);
sint = sin(2*pi*t);
x = bw_o.*cost;
y = bw_e.*sint;
z = x+y;
subplot(3,2,1);
plot(t,bw);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Input Bit Stream');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,5);
plot(t,bw_o);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Odd Sequence');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,3);
plot(t,bw_e);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Even Sequence');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,4);
plot(t,x);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Odd Sequence BPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,2);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Even Sequence BPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,6);
plot(t,z);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('QPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);



Output:

Enter the bit stream = [0 1 1 0 1 0 0 0]


Output Waveforms:

BFSK (Matlab 2012a)

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:i+1
bw(x(i*100:(i+1)*100)) = u(i);
end
end
bw = bw(100:end);
wo = 2*(2*pi*t);
W = 1*(2*pi*t);
sinHt = sin(wo+W);
sinLt = sin(wo-W);
st = sin(wo+(bw).*W);
subplot(4,1,1);
plot(t,bw);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Input Bit Stream');
grid on ;
axis([0 n -2 +2]);
subplot(4,1,2);
plot(t,sinHt);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Wave 1');
grid on ;
axis([0 n -2 +2]);
subplot(4,1,3);
plot(t,sinLt);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Wave 2');
grid on ;
axis([0 n -2 +2]);
subplot(4,1,4);
plot(t,st);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('BFSK Wave');
grid on ;
axis([0 n -2 +2]);


Output:

Enter the bit stream = [0 1 1 0 1 0 0 0]

Output Waveform:

 

BPSK (Matlab 2012a)

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:i+1
bw(x(i*100:(i+1)*100)) = u(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([0 n -2 +2]);
subplot(3,1,2);
plot(t,sint);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,1,3);
plot(t,st);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('BPSK Wave');
grid on ;
axis([0 n -2 +2]);


Output:

Enter the bit stream = [0 1 1 0 1 0 0 0] 

Output Waveforms:

 

ASK (Matlab 2012a)

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
for j = i:0.1:i+1
bw(x(i*100:(i+1)*100)) = b(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([0 n -2 +2]);
subplot(3,1,2);
plot(t,sint);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,1,3);
plot(t,st);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('ASK Wave');
grid on ;
axis([0 n -2 +2]);


Output:

Enter the Bit stream = [0 1 1 0 1 0 0 0]

Output Waveforms:

 

Error Probability Curve of M-ary PAM (Matlab 2012a)

Program:

clc;
clear all;
n = input('Enter the number of values to be compared = ');
colour = ['k', 'g', 'r', 'b', 'y'];
nsample = 1;
m = 4;
for i = 1:n
    eb_db = 0:0.0001:25;
    k = log2(m);
    es_db = eb_db + 10*log(k) + 10*log(nsample);
    es = db2mag(es_db);
    z = sqrt(6*es/(m*(m-1)));
    p = 2*((m-1)/m)*qfunc(z);
    semilogy(eb_db,p,colour(k));
    hold on;
    m = m*2;
end
xlabel('SNR ----->');
ylabel('Probability of Error ----->');
title('Error Probability Curve of M ary PAM');
grid on;
legend('m = 4','m = 8', 'm = 16', 'm = 32');


Output:

Enter the number of values to be compared = 3

Output Graph:


Comparison of Error Probability Curve of M-ary PSK & M-ary PAM (Matlab 2012a)

Program
clc;
clear all;
m = input('Enter the value of m = ');
eb_no = 0:0.001:25;
k = log2(m);
nsample = 1;
es_db = eb_no + 10*log(k) + 10*log(nsample);
es = db2mag(es_db);
z = sqrt(6*es/(m*(m-1)));
p_pam = 2*((m-1)/m)*qfunc(z);
semilogy(eb_no,p_pam,'g');
hold on;
p_mpsk = 2*qfunc(sqrt(2*es)).*sin(pi/m);
semilogy(eb_no,p_mpsk,'r');
xlabel('SNR ----->');
ylabel('Probability of Error ----->');
title('Comparison of Probability of error of MPAM & MPSK');
grid on;
legend('MPSK','MPAM');


Output:

Enter the value of m = 4

OutputGraph:

 

Wednesday, 17 October 2012

Analysis of M ary PSK (Matlab 2012a)

Program:

clc;
clear all;
%Create a random digital message
M = input('Enter alphabet size M = '); %Alphabet Size
k = log2(M);
x = randi([0 1],input('Number of binary bit stream = '),1); %Message Signal
nsample = 1;
%Bit to symbol Mapping
% Convert the bits in x to k bit symbols
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');
%Stem plot of symbols
% Plot first 10 symbols in a stem plot
subplot(3,2,1);
stem(xsym(1:10),'filled');
title('Input Message Random Symbols (Decimal)');
xlabel('Symbol Index ----->');
ylabel('Integer Value ----->');
grid on;
hold on;
y = modulate(modem.pskmod(M),xsym);%M ary PSK modulation
subplot(3,2,2);
stem(y(1:10),'filled');
title('Modulated Signal');
xlabel('n ---->');
ylabel('Amplitude ---->');
grid on;
hold on;
%Transmitting signal through an AWGN Channel
ynoisy = awgn(y,input('SNR in dB = '),'measured');
%Demodulate ynoisy to recover the message
zsym = demodulate(modem.pskdemod(M),ynoisy);
% Symbol-to-Bit Mapping
% Undo the bit-to-symbol mapping performed earlier
z = de2bi(zsym,'left-msb'); % Convert integers to bits
% Convert z from a matrix to a vector
z = reshape(z.',numel(z),1);
subplot(3,2,3);
stem(x(1:10),'filled');
title('Original Message Sequence (Binary)');
xlabel('n ---->');
ylabel('Amplitude ---->');
grid on;
hold on;
subplot(3,2,4);
stem(zsym(1:10),'filled');
title('Demodulated Message Sequence (Decimal)');
xlabel('n ---->');
ylabel('Amplitude ---->');
grid on;
hold on;
subplot(3,2,5);
stem(z(1:10),'filled');
title('Demodulated Message Sequence (Binary)');
xlabel('n ---->');
ylabel('Amplitude ---->');
grid on;
hold on;
[num,r] = symerr(xsym,zsym);%Calculating symbol error rate
disp('Number of Symbol Errors = ');
disp(num);
disp('Symbol Error Rate = ');
disp(r);
[numbr,ra] = biterr(x,z);%Calculating bit error rate
disp('Number of Bit Errors = ');
disp(numbr);
disp('Bit Error Rate = ');
disp(ra);
h = modem.pskmod(M);% Modulator object
mapping = h.SymbolMapping; % Symbol mapping vector
pt = h.Constellation; % Vector of all points in constellation
% Plot the constellation
scatterplot(pt);

title('Signal Constellation');
% Include text annotations that number the points
text(real(pt)+0.1,imag(pt),dec2bin(mapping));
axis([-2 2 -2 2]); %Change axis so all labels fit in plot


Output:

 
Enter alphabet size M = 16
Number of binary bit stream = 4000
SNR in dB = 10
Number of Symbol Errors =
   393

Symbol Error Rate =
    0.3930

Number of Bit Errors =
   753

Bit Error Rate =
    0.1883


Waveforms:

 

 

Thursday, 11 October 2012

Parity Check (Matlab 2012a)

Program:
clc;
clear all;
b = input('Enter the bit stream = ');
pr = input('Enter the error probability = ');
n = length(b);
c = 0;
for i = 1:n
        if(b(i)==1)
        c = c + 1;
        end
end
if(mod(c,2)~=0)
   b1 = [b ones(1,1)];
else
   b1 = [b zeros(1,1)];
end
l = length(b1);
disp('Input bit stream = ');
disp(b);
disp('Transmitting message sequence including parity bit = ');
disp(b1);
[ncode,err] = bsc(b1,pr);
disp('Received message sequence = ');
disp(ncode);
for i = 1:n
    if(ncode(l)~=b1(l))
        disp('Parity error');
        break;
    end
    if(ncode(i)~=b1(i))
        disp('Transmitted and received sequence does not match');
        break;
    else
        if(i==n)
       disp('Transmitted and received sequence match');
        end
    end
end


Output 1:


Enter the bit stream = [0 1 1 0 1 0]
Enter the error probability = 0.9
Input bit stream =
     0     1     1     0     1     0

Transmitting message sequence including parity bit =
     0     1     1     0     1     0     1

Received message sequence =
     1     0     0     1     1     1     1

Transmitted and received sequence does not match


Output 2:

Enter the bit stream = [0 1 1 0 1 0]
Enter the error probability = 0.7
Input bit stream =
     0     1     1     0     1     0

Transmitting message sequence including parity bit =
     0     1     1     0     1     0     1

Received message sequence =
     1     0     0     0     0     1     0


Parity error


Output 3:

 Enter the bit stream = [0 1 1 0 1 0]
Enter the error probability = 0.1
Input bit stream =
     0     1     1     0     1     0

Transmitting message sequence including parity bit =
     0     1     1     0     1     0     1

Received message sequence =
     0     1     1     0     1     0     1

Transmitted and received sequence match



Tuesday, 18 September 2012

MSK (Matlab 2012a)

Program:
clc;
clear all;
b = input('Enter the Bit stream = ');
n = length(b);
t = 0:0.01:n;
x = 1:1:(n+2)*100;
for i = 1:n
if (b(i) == 0)
u(i) = -1;
else
u(i) = 1;
end
for j = i:0.1:i+1
bw(x(i*100:(i+1)*100)) = u(i);
if (mod(i,2) == 0)
bw_o(x(i*100:(i+1)*100)) = u(i);
bw_o(x((i+1)*100:(i+2)*100)) = u(i);
else
bw_e(x(i*100:(i+1)*100)) = u(i);
bw_e(x((i+1)*100:(i+2)*100)) = u(i);
end
if (mod(n,2)~= 0)
bw_o(x(n*100:(n+1)*100)) = -1;
bw_o(x((n+1)*100:(n+2)*100)) = -1;
end
end   
end
bw = bw(100:end);
bw_e = bw_e(100:(n+1)*100);
bw_o = bw_o(200:(n+2)*100);
wo = 2*pi*t*(5/4);
Wt = 2*pi*t/(4*1);
st = bw_o.*sin(wo+(bw_e.*bw_o).*Wt);
subplot(4,1,1);
plot(t,bw);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Input Bit Stream');
grid on;
axis([0 n -2 +2]);
subplot(4,1,2);
plot(t,bw_o);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Odd Sequence');
grid on;
axis([0 n -2 +2]);
subplot(4,1,3);
plot(t,bw_e);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Even Sequence');
grid on;
axis([0 n -2 +2]);
subplot(4,1,4);
plot(t,st);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('MSK Modulated Wave');
grid on;
axis([0 n -2 +2]);

Output:
Enter the Bit stream = [1 0 1 1 1 0 1]

Waveform: