Showing
5 changed files
with
114 additions
and
0 deletions
No preview for this file type
No preview for this file type
... | @@ -112,6 +112,7 @@ | ... | @@ -112,6 +112,7 @@ |
112 | <ItemGroup> | 112 | <ItemGroup> |
113 | <ClCompile Include="constellation_main.cpp" /> | 113 | <ClCompile Include="constellation_main.cpp" /> |
114 | <ClCompile Include="myMatrix.cpp" /> | 114 | <ClCompile Include="myMatrix.cpp" /> |
115 | + <ClCompile Include="sender.cpp" /> | ||
115 | </ItemGroup> | 116 | </ItemGroup> |
116 | <ItemGroup> | 117 | <ItemGroup> |
117 | <ClInclude Include="channel.h" /> | 118 | <ClInclude Include="channel.h" /> | ... | ... |
... | @@ -21,6 +21,9 @@ | ... | @@ -21,6 +21,9 @@ |
21 | <ClCompile Include="myMatrix.cpp"> | 21 | <ClCompile Include="myMatrix.cpp"> |
22 | <Filter>소스 파일</Filter> | 22 | <Filter>소스 파일</Filter> |
23 | </ClCompile> | 23 | </ClCompile> |
24 | + <ClCompile Include="sender.cpp"> | ||
25 | + <Filter>소스 파일</Filter> | ||
26 | + </ClCompile> | ||
24 | </ItemGroup> | 27 | </ItemGroup> |
25 | <ItemGroup> | 28 | <ItemGroup> |
26 | <ClInclude Include="sender.h"> | 29 | <ClInclude Include="sender.h"> | ... | ... |
constellation/constellation/sender.cpp
0 → 100644
1 | +#ifndef __SENDER | ||
2 | +#define __SENDER | ||
3 | +#define PI 3.1415926535 | ||
4 | +#include <iostream> | ||
5 | +using namespace std; | ||
6 | +#include <cmath> | ||
7 | +#include "variables.h" | ||
8 | +#include "myMatrix.h" | ||
9 | +#include "sender.h" | ||
10 | +class Csender { | ||
11 | +public: | ||
12 | + Csender() {}; | ||
13 | + char data[Nbits]; | ||
14 | + float s[Nbits / Nbitspersymbol*Nsamplespersymbol]; // trasmitted signal | ||
15 | + void transmitData(); | ||
16 | +}; | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | +char data[Nbits]; | ||
21 | +float s[Nbits / Nbitspersymbol*Nsamplespersymbol]; // trasmitted signal | ||
22 | + | ||
23 | + | ||
24 | +void Csender::transmitData() | ||
25 | +{ | ||
26 | + float T; | ||
27 | + float f0, f1; | ||
28 | + float A; | ||
29 | + float c0[20], c1[20]; | ||
30 | + float t[20]; | ||
31 | + | ||
32 | + float data0[500]; | ||
33 | + float data1[500]; | ||
34 | + | ||
35 | + | ||
36 | + for (int i = 0; i < Nbits; i++) | ||
37 | + { | ||
38 | + data[i] = rand() % 2; | ||
39 | + } | ||
40 | + | ||
41 | + T = 1000.0; //ֱ? ? | ||
42 | + f0 = 1 / T; f1 = 1 / T; | ||
43 | + A = 5.0; | ||
44 | + | ||
45 | + for (int j = 0; j < Nbits; j++) | ||
46 | + { | ||
47 | + if (j % 2 == 0) | ||
48 | + { | ||
49 | + data0[j / 2] = data[j]; | ||
50 | + } | ||
51 | + else if (j % 2 == 1) | ||
52 | + { | ||
53 | + data1[j / 2] = data[j]; | ||
54 | + } | ||
55 | + } | ||
56 | + //showMatrix(1, 1000, data0); | ||
57 | + //showMatrix(1, 1000, data1); | ||
58 | + | ||
59 | + float data00[Nbits / 2]; | ||
60 | + float data11[Nbits / 2]; | ||
61 | + | ||
62 | + for (int k = 0; k < Nbits / 2; k++) | ||
63 | + { | ||
64 | + if (data0[k] == 0) | ||
65 | + { | ||
66 | + data00[k] = A; | ||
67 | + } | ||
68 | + else if (data0[k] == 1) | ||
69 | + { | ||
70 | + data00[k] = -A; | ||
71 | + } | ||
72 | + | ||
73 | + if (data1[k] == 0) | ||
74 | + { | ||
75 | + data11[k] = A; | ||
76 | + } | ||
77 | + else if (data1[k] == 1) | ||
78 | + { | ||
79 | + data11[k] = -A; | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + | ||
84 | + //showMatrix(1, 1000, data00); | ||
85 | + //showMatrix(1, 1000, data11); | ||
86 | + | ||
87 | + for (int i = 0; i <20; i++) | ||
88 | + { | ||
89 | + t[i] = T / 20.0; | ||
90 | + } | ||
91 | + | ||
92 | + for (int i = 0; i < 20; i++) | ||
93 | + { | ||
94 | + c0[i] = sqrt(2 / T)*cos(2 * PI*f0*t[i]); | ||
95 | + c1[i] = sqrt(2 / T)*sin(2 * PI*f1*t[i]); | ||
96 | + } | ||
97 | + | ||
98 | + float s0[Nbits / Nbitspersymbol*Nsamplespersymbol]; | ||
99 | + float s1[Nbits / Nbitspersymbol*Nsamplespersymbol]; | ||
100 | + | ||
101 | + matrixmult(500, 1, 20, data00, c0, s0); | ||
102 | + matrixmult(500, 1, 20, data11, c1, s1); | ||
103 | + matrixadd(500, 20, s0, s1, s); | ||
104 | + | ||
105 | + | ||
106 | + showMatrix(1, 10000, s); | ||
107 | + | ||
108 | +} | ||
109 | + | ||
110 | +#endif | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment