Pages

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:

15 comments:

  1. hey,what about demodulation of Qpsk from here
    ..

    ReplyDelete
  2. hi Nebu,
    i am also doing a project on qpsk implementation. if you could post the matlab code for Demodulator also, it would be a great help.
    Thanks a million for posting the modulator code..

    ReplyDelete
  3. 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
    NO NEED OF DIS.....PLS...

    ReplyDelete
  4. how to expain OQPSK ?...
    plz..

    ReplyDelete
  5. wav...thank u so much bro...:)

    ReplyDelete
  6. neead code for qpsk demodulator also...

    ReplyDelete
  7. Please, do you have the code for the QPSK demodulation

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Hi , can you help us in 4FSK modulation and demodulation..

    ReplyDelete
  11. hi please can you explain me this line
    x = 1:1:(n+2)*100;

    what does "x" refer to?

    ReplyDelete