Pages

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: