# The official reference “DSP code” is incorrect

Dear All

When I wanted to simulate an DP-8PSK communication system. But I got the wrong answer when I used the official example.

What I want to do is to add a matlab component between the two DSPs to add my own algorithm.

The code given by the official website is as follows:

OutputPort1 = InputPort1;

OutputPort2 = InputPort2;

OutputPort3 = InputPort3;

OutputPort4 = InputPort4;

IX = InputPort1.Sampled.Signal;

QX = InputPort2.Sampled.Signal;

IY = InputPort3.Sampled.Signal;

QY = InputPort4.Sampled.Signal;

SampleperSymbol = 1;

BitLength = 32768;

symbolNum = BitLength/6; % For DP QPSK, symbolNum = BitLength/4.

sampleNum = length(IX);

NumDownSamp = round(sampleNum/(symbolNum * SampleperSymbol));

SamplePoint = floor(NumDownSamp/2);

IX = downsample(IX, NumDownSamp, SamplePoint);

QX = downsample(QX, NumDownSamp, SamplePoint);

IY = downsample(IY, NumDownSamp, SamplePoint);

QY = downsample(QY, NumDownSamp, SamplePoint);

% Insert your algorithm here

% my code

%

% Upsampling

NumOutputSamp = length(InputPort1.Sampled.Signal);

NumSamp = length (IX);

NumUpSamp = round(NumOutputSamp/NumSamp);

IX_out = zeros(1, NumOutputSamp);

QX_out = zeros(1, NumOutputSamp);

IY_out = zeros(1, NumOutputSamp);

QY_out = zeros(1, NumOutputSamp);

for j = 1 : NumSamp

IX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IX(j);

QX_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QX(j);

IY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*IY(j);

QY_out(1+(j-1)*NumUpSamp : j*NumUpSamp) = ones(1, NumUpSamp).*QY(j);

end

OutputPort1.Sampled.Signal = IX_out;

OutputPort2.Sampled.Signal = QX_out;

OutputPort3.Sampled.Signal = IY_out;

OutputPort4.Sampled.Signal = QY_out;

However, I was told by matlab that this is wrong, because the ones(1, NumUpSamp) requires NumUpSamp to be an integer, but NumUpSamp=24.0015

### Responses (4):

Login You must be logged in to reply to this topic.