Pages

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:

 

DSBSC (Matlab 2012a)

Program:

clc;
clear all;
vm = input('Enter the message signal amplitude = ');
vc = input('Enter the carrier signal amplitude = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = vm/vc;
t = 0:0.001:1;
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal ---->');
grid on;
sc = sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal ---->');
grid on;
y = vc*m.*sin(2*pi*fm*t).*sin(2*pi*fc*t);
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('DSBSC Wave ---->');
grid on;


Output:

Enter the message signal amplitude = 5
Enter the carrier signal amplitude = 10
Enter the message frequency = 10
Enter the carrier frequency = 100


Output Waveform:




Phase Modulation (Matlab 2012a)

Program:

clc;

clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*sin(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('PM Wave');
grid on;

Output:


Enter the amplitude of message signal = 5

Enter the amplitude of carrier signal = 5
Enter the message frequency = 10
Enter the carrier frequency = 100
Enter modulation index = 4

Output Waveforms:



Frequency Modulation (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = input('Enter modulation index = ');
sm = vm*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = vc*sin(2*pi*fc*t+m.*cos(2*pi*fm*t));
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('FM Signal');
grid on;


Output:

Enter the amplitude of message signal = 5
Enter the amplitude of carrier signal = 5
Enter the message frequency = 10
Enter the carrier frequency = 100
Enter modulation index = 4


Output Waveform:

 

Amplitude Modulation (Matlab 2012a)

Program:

clc;
clear all;
t = 0:0.001:1;
vm = input('Enter the amplitude of message signal = ');
vc = input('Enter the amplitude of carrier signal = ');
fm = input('Enter the message frequency = ');
fc = input('Enter the carrier frequency = ');
m = vm/vc;
sm = vm.*sin(2*pi*fm*t);
subplot(3,1,1);
plot(t,sm);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Message Signal');
grid on;
sc = vc.*sin(2*pi*fc*t);
subplot(3,1,2);
plot(t,sc);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Carrier Signal');
grid on;
y = (vm+m*vm.*sin(2*pi*fm*t)).*sin(2*pi*fc*t);
subplot(3,1,3);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('AM Signal');
grid on;


Output:

Enter the amplitude of message signal = 5
Enter the amplitude of carrier signal = 10
Enter the message frequency = 10
Enter the carrier frequency = 100

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



High Pass Filter - First Order AR Process (Matlab 2012a)

Program:
clc;
clear all;
n = input('Enter the no. of values:');
colr = ['g','b','r','k'];
for i = 1:n
    r = input('Enter the value for r:');
    d0 = 1+(r*r)+ 2*r;
    w1 = 0:0.001:pi;
    d1 = 1+(r*r)-(2*r.*cos(w1));
    ps = d0./d1;
    hold on;
    semilogy(w1,ps,colr(i));
end
xlabel('Frequency(Units of pi)');
ylabel('Power Spectrum');
title('Response of High Pass Filter');
legend('r=.5','r=.75','r=.9');


Output:

 
Enter the no. of values: 3
Enter the value for r: -0.5
Enter the value for r: -0.75
Enter the value for r: -0.9


Output Graph:

 

Low Pass Filter - First Order AR Process (Matlab 2012a)

Program :
clc;
clear all;
n = input('Enter the no. of values:');
colr = ['g','b','r','k'];
for i = 1:n
    r = input('Enter the value for r:');
    d0 = 1+r*r-2*r;
    w1 = 0:0.001:1;
    d1 = 1+(r*r)-(2*r.*cos(w1));
    ps = d0./d1;
    hold on;
    semilogy(w1,ps,colr(i));
end
xlabel('Frequency(Units of pi)');
ylabel('Power Spectrum');
title('Response of Low Pass Filter');
legend('r=.5','r=.75','r=.9');


Output:

 
Enter the no. of values: 3
Enter the value for r: 0.5
Enter the value for r: 0.75
Enter the value for r: 0.9


Output Graph:

 


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: