This repository has been archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ChannelQPSK.m
42 lines (37 loc) · 1.62 KB
/
ChannelQPSK.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function [ carrierWawe, timeAxis, numberOfSamplesInSymbol, x, y ] = ChannelQPSK( WAWE_FREQUENCY, BIT_NUMBER, bitArray, sigmaU, sigmaOmega )
sampleFrequency = 20000; % czestotliwosc probkowania [Hz]
amplitude = 0.5; % amplituda
signalLength = (1/WAWE_FREQUENCY)*(BIT_NUMBER/2);
symbolLength = (1/WAWE_FREQUENCY);
numberOfSamples = signalLength*sampleFrequency;
numberOfSamplesInSymbol = symbolLength*sampleFrequency;
timeAxis = 0:1/(sampleFrequency):(numberOfSamples-1)/(sampleFrequency);
carrierWawe = zeros(1, numberOfSamplesInSymbol*(BIT_NUMBER/2));
x= zeros(1, floor(BIT_NUMBER/2));
y= zeros(1, floor(BIT_NUMBER/2));
for i = 1:(BIT_NUMBER/2)
if bitArray(2*i) == 0
if bitArray((2*i)-1) == 0
offset = 0.625;
end
if bitArray((2*i)-1) == 1
offset = 0.875;
end
end
if bitArray(2*i) == 1
if bitArray((2*i)-1) == 0
offset = 0.375;
end
if bitArray((2*i)-1) == 1
offset = 0.125;
end
end
amplitudeDist = sigmaU*randn();
sigmaDist = sigmaOmega*randn();
x(i)=(amplitudeDist+amplitude)*cos(2*pi*(offset + sigmaDist));
y(i)=(amplitudeDist+amplitude)*sin(2*pi*(offset + sigmaDist));
for j = 1:numberOfSamplesInSymbol
carrierWawe(((i-1)*numberOfSamplesInSymbol)+j) = (amplitudeDist+amplitude)*cos(2*pi*WAWE_FREQUENCY*timeAxis(((i-1)*numberOfSamplesInSymbol)+j) + 2*pi*(offset + sigmaDist));
end
end
end