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,1,1,0,0,0,1,1,0,0;
   1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0];

   tx = [];
   values = randsrc(1,1,[0:15]);
   for k=1:length(values)
    sym = values(k);
    tx = [tx chip_values((sym+1),1:end)];
   end;

   tx = tx.';
   h = modem.oqpskmod;
   y = modulate(h, tx);
   g = modem.oqpskdemod(h);
   z = demodulate(g, y);
   length(z)
   for k=1:length(tx)
    if(tx(k)~=z(k))
     fprintf('%d %d\n',tx(k),z(k)); 
    end;
   end;

my question is in this simple case why my tx and z do not contain the same values eventhough i did not introduce any noise yet? thanks!

values of tx comes as follows:

Columns 1 through 13

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

Columns 14 through 26

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

Columns 27 through 32

 0     0     1     0     0     1

values of the z comes as follows:

Columns 1 through 13

 3     0     1     1     0     0     0     0     0     0     1     1     1

Columns 14 through 26

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

Columns 27 through 32

 1     0     0     1     0     0


  h =

         Type: 'OQPSK Modulator'
            M: 4
  PhaseOffset: 0
Constellation: [1x4 double]
  SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
    InputType: 'Integer'

  g =

         Type: 'OQPSK Demodulator'
            M: 4
  PhaseOffset: 0
Constellation: [1x4 double]
  SymbolOrder: 'Binary'
SymbolMapping: [0 1 2 3]
   OutputType: 'Integer'
 DecisionType: 'Hard decision'
A: 

It's hard for me to tell since I don't have the communications toolbox installed, but I would suggest trying this with a simpler input as given in the examples in the documentation. Use

tx = randint(10,1,8) 

for instance. Then look at the output rather than just comparing. Are the differences at or near machine precision? You don't tell us what is printed out (are they matching or not?). Try taking the difference between tx and z. Is it near eps (2.2204e-016 for me)?

Is there a shifting between the data going in and the data coming out? Tell us what is going on with the data.

Update

I'm glad that you posted that actual input and output. It looks like z is shifted one to the right (and has a 3 at the beginning for some reason) which means you lose the last bit. Looking at the Matlab documentation, there is a note that says

OQPSK demodulators have a 1 symbol delay.

I think that explains the problem. Basically, just pad an extra 0 at the end of the input to the modulator, take off the first element from the output of the demodulator, and you're in business.

Justin Peel
sorry for late response, i have given more info... thanks in advance!
kl

related questions