Question

Could you please help me with this assignment?

The purpose of this assignment is to simulate the transmission and reception of a text message
(i.e., character string) over a noisy communications channel. Suppose we wish to transmit the
string “Hello.” We can translate this string into a bit stream as shown below:
String: H e l l o . \0 (note: the last character \0 is the null terminator character)
ASCII: 72 101 108 108 111 46 0
Binary: 01001000 01100101 01101100 01101100 01101111 00101110
00000000
Notice how this string can be expressed as 8 x 7 = 56 bits. Suppose we transmit each of these
bits as voltages on an electrical signal (for simplicity, +1.0 V for binary 1 and 0.0 V for binary 0).
We can simulate noise by encoding these bits in a double array of length 56 and then adding
noise samples to the 1.0 and 0.0 values that will initially be loaded into the array. With a small
amount of noise (low SNR), the values in this array for the first character “H” may be:
0.0143, 0.9985, -0.00124, 0.1076, 1.00325, 0.00173, 0.0563, 0.00474
With low noise, it is clear that the voltages “near” 0 represent binary 0 and the voltages “near” 1
represent binary 1. As a general rule, a receiver will take any voltages less than 0.5 and treat
them as binary 0 and any voltages greater than or equal to 0.5 and treat them as binary 1.

Problem:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

double guassian_noise(double mu, double sigma)
{
static double U, V;
static int sample = 0;
double X; // this will be the outputted random guassian number

if(sample == 0)
{
U = ((double) rand())/RAND_MAX;
V = ((double) rand())/RAND_MAX;
X = sqrt(-2*log(U))*cos(2*M_PI*V);
}
else
{
X = sqrt(-2*log(U))*sin(2*M_PI*V);
}

sample = (sample+1)%2;
return sigma*X + mu;
}

double compute_sigma(double *signal, double snr, int size)
{
double p = 0;

int i;

for(i = 0; i < size; i++)
{
p += signal[i]*signal[i];
}

p = p/size;

snr = snr*(0.1);
double sigma = sqrt((p/pow(10, snr)));
return sigma;
}

double* add_noise(double *signal, double snr, int size)
{
int i = 0;
double sigma = compute_sigma(signal, snr, size);
for(i = 0; i < size; i++)
{
double noise = guassian_noise(0, sigma);
signal[i] += noise;
}
return signal;
}

int main()
{
double signal[] = {1,1,1,1,1,1,1,1,1,0};
add_noise(signal, 2, 10);

int i = 0;

for(i = 0; i < 10; i++)
{
printf("%f\n", signal[i]);
}

return 0;
}

/*

In driver program please set appropriate value of snr and array

*/

Add a comment
Know the answer?
Add Answer to:
Could you please help me with this assignment? The purpose of this assignment is to simulate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • matlab help, please my code is here: %% exercise2 %a Fs = 8000; % sampling frequency tn = 0:1/Fs:0.005; % here, bit dura...

    matlab help, please my code is here: %% exercise2 %a Fs = 8000; % sampling frequency tn = 0:1/Fs:0.005; % here, bit duration is 0.005s instead of 1/300s phi1 = 0; phi0 = 0; % phases of the sinusoid x1 = cos(2*pi*1650*tn + phi1); % tone for binary 1 x0 = cos(2*pi*1850*tn + phi0); % tone for binary 0 xx = [x1, x0]; % FSK signal for ¡°1,0¡± tt = [tn, tn + 0.005]; % time figure(1) plot(tt, xx); %...

  • Help me please! Thank you!! 1. Consider the signal set in Figure 1 for binary data...

    Help me please! Thank you!! 1. Consider the signal set in Figure 1 for binary data transmission over a channel disturbed by AWGN. The noise is zero-mean and has two-sided PSD No/2. As usual, si(t) is used for the transmission of bit "0" and s2(t) is for the transmission of bit 1." Furthermore, the two bits are equiprobable. Si CC) s2(t) .A 0 Figure 1: A binary signal set, considered in Problem 1 Find and draw an orthonormal basis {фі...

  • Could you please help me with an answer to this question in a simple way for...

    Could you please help me with an answer to this question in a simple way for the beginner? This is a beginner level class so can you please help me. The code must have beginner level implementation. Can you also please explain what things do. Thank you! Write a program that prompts the user for a positive integer number smaller than 256 (i.e. in [0...255]) and converts it into an 8-bit binary number. The bits are the remainders of the...

  • Hello I have an automata question could you help me? [1Points] Give a formal description of a Tu...

    Hello I have an automata question could you help me? [1Points] Give a formal description of a Turing Machine M  that takes two parameters: an integer and an array of integers and decides whether the given integer is an element of the array or not. You can assume that all the integers are between 0 and 9. The input string will be written on the tape of the Turing machine. The first square of the tape contains the integer, the...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • COULD YOU PLEASE HELP ME************************** write a better mode computation function that uses the ideas in...

    COULD YOU PLEASE HELP ME************************** write a better mode computation function that uses the ideas in the word file and improves on the mode computation function in the cpp file. ===========source.cpp #include <ctime> #include <iomanip> #include <iostream> #include <string> #include <random> using namespace std; default_random_engine e(static_cast<unsigned>(time(NULL))); void fill(int a[], int size, int value) { for(int i = 0; i < size; i++) a[i] = value; } void randomFill(int a[], int size, int lb, int up) { uniform_int_distribution<int> u(lb, up); for(int...

  • Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditiona...

    Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditional and iterative control structures that repeat actions as needed. The unit measurement is missing from the final output and I need it to offer options to lbs, oz, grams, tbsp, tsp, qt, pt, and gal. & fl. oz. Can this be added? The final output...

  • I need help with this assignment. It's due Tuesday at 8 AM. Please follow the instructions thorou...

    I need help with this assignment. It's due Tuesday at 8 AM. Please follow the instructions thoroughly as to not use any advanced material we may not have gone over in class. The instructions let you know what all should be used. Thanks! Use only what you have learned in Chapters 1 - 7. Use of "advanced" material, material not in the text, or project does not follow the instructions, will result in a GRADE OF 0% for the project....

  • For this assignment, you will write a program to work with Huffman encoding. Huffman code is...

    For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT