Showing
1 changed file
with
17 additions
and
2 deletions
| ... | @@ -6,9 +6,24 @@ | ... | @@ -6,9 +6,24 @@ |
| 6 | #include "variables.h" | 6 | #include "variables.h" |
| 7 | class Cchannel { | 7 | class Cchannel { |
| 8 | public: | 8 | public: |
| 9 | - Cchannel() {}; | 9 | + Cchannel(); |
| 10 | float *s; // trasmitted signal | 10 | float *s; // trasmitted signal |
| 11 | - float r[Nbits / Nbitspersymbol*Nsamplespersymbol]; // corrupted signal | 11 | + float r[Nbits]; // corrupted signal |
| 12 | + float noise[Nbits]; | ||
| 12 | void AWGN(); | 13 | void AWGN(); |
| 13 | }; | 14 | }; |
| 15 | + | ||
| 16 | +Cchannel::Cchannel() | ||
| 17 | +{ | ||
| 18 | + default_random_engine generator; | ||
| 19 | + normal_distribution<double> myGauss(0, No / 2); | ||
| 20 | + for (int i = 0; i < Nbits; i++) | ||
| 21 | + noise[i] = myGauss(generator); | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +void Cchannel::AWGN() | ||
| 25 | +{ | ||
| 26 | + for (int i = 0; i < Nbits; i++) | ||
| 27 | + r[i] = s[i] + noise[i]; | ||
| 28 | +} | ||
| 14 | #endif | 29 | #endif |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment