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
/
Channel8QAM.m
72 lines (65 loc) · 2.67 KB
/
Channel8QAM.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [carrierWawe, timeAxis, x, y] = Channel8QAM(WAWE_FREQUENCY, BIT_NUMBER, bitArray, sigmaU, sigmaOmega)
sampleFrequency = 20000; % czestotliwosc probkowania [Hz]
amplitude = 0.5; % amplituda, pamietaj zmienic rowniez w demodulatorze; programista plakal jak programowal
signalLength = (1/WAWE_FREQUENCY)*(BIT_NUMBER/3);
symbolLength = (1/WAWE_FREQUENCY);
numberOfSamples = signalLength*sampleFrequency;
numberOfSamplesInSymbol = symbolLength*sampleFrequency;
timeAxis = 0:1/(sampleFrequency):(numberOfSamples-1)/(sampleFrequency);
carrierWawe = zeros(1, floor(numberOfSamplesInSymbol*(BIT_NUMBER/3)));
x= zeros(1, floor(BIT_NUMBER/3));
y= zeros(1, floor(BIT_NUMBER/3));
for i = 1:(BIT_NUMBER/3)
if bitArray(3*i) == 0
if bitArray((3*i)-1) == 0
if bitArray((3*i)-2) == 0
amplitudeOffset = 0.5;
offset = 0.625;
end
if bitArray((3*i)-2) == 1
amplitudeOffset = 1;
offset = 0.5;
end
end
if bitArray((3*i)-1) == 1
if bitArray((3*i)-2) == 0
amplitudeOffset = 1;
offset = 0.75;
end
if bitArray((3*i)-2) == 1
amplitudeOffset = 0.5;
offset = 0.375;
end
end
end
if bitArray(3*i) == 1
if bitArray((3*i)-1) == 0
if bitArray((3*i)-2) == 0
amplitudeOffset = 1;
offset = 0;
end
if bitArray((3*i)-2) == 1
amplitudeOffset = 0.5;
offset = 0.125;
end
end
if bitArray((3*i)-1) == 1
if bitArray((3*i)-2) == 0
amplitudeOffset = 0.5;
offset = 0.875;
end
if bitArray((3*i)-2) == 1
amplitudeOffset = 1;
offset = 0.25;
end
end
end
amplitudeDist = sigmaU*randn();
sigmaDist = sigmaOmega*randn();
x(i)=(amplitudeDist+(amplitude*amplitudeOffset))*cos(2*pi*(offset + sigmaDist));
y(i)=(amplitudeDist+(amplitude*amplitudeOffset))*sin(2*pi*(offset + sigmaDist));
for j = 1:numberOfSamplesInSymbol
carrierWawe(((i-1)*numberOfSamplesInSymbol)+j) = (amplitudeDist+(amplitude*amplitudeOffset))*cos(2*pi*WAWE_FREQUENCY*timeAxis(((i-1)*numberOfSamplesInSymbol)+j) + 2*pi*(offset + sigmaDist));
end
end
end