Question

Write a code in matlab for AWGN () function. (please comment each line of the code...

Write a code in matlab for AWGN () function. (please comment each line of the code to know what each line does)

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


f u n c ti o n [y,n] = add_awgn_noise(x,SNR_dB)
%[y,n]=awgn_noise(x,SNR) adds AWGN noise vector to signal ’x’ to generate a
%resulting signal vector y of specified SNR in dB. It also returns the
%noise vector ’n’ that is added to the signal x
L=l e n g t h(x);
SNR = 10ˆ(SNR_dB/10); %SNR to linear scale
Esym=sum(abs(x).ˆ2)/(L); %Calculate actual symbol energy
N0=Esym/SNR; %Find the noise spectral density
i f ( i s r e a l (x)),
noiseSigma = s q r t(N0);%Standard deviation for AWGN Noise when x is real
n = noiseSigma*randn(1,L);%computed noise
e l s e
noiseSigma=s q r t(N0/2);%Standard deviation for AWGN Noise when x is complex
n = noiseSigma*(randn(1,L)+1i*randn(1,L));%computed noise
end
y = x + n; %received signal
end

Add a comment
Know the answer?
Add Answer to:
Write a code in matlab for AWGN () function. (please comment each line of the code...
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
  • Please use MatLab and comment code. Problem 2 Write a MATI AB user-defined function y-M?SotxType): x...

    Please use MatLab and comment code. Problem 2 Write a MATI AB user-defined function y-M?SotxType): x is a vector containing numbers. and Type can be 'Ascending' or Descending'. This function should sort the given vector x in the ascending or descending order based on the user's request and return the desired vector as the output. Do not use MATLAB built-in function sort. Hint: When you call this function you need to use for Ascending or Descending since they are strings.

  • Consider the function f(x) = x3 – 2x2 + x Write the MATLAB code in the...

    Consider the function f(x) = x3 – 2x2 + x Write the MATLAB code in the format of "script file" using "Regula Falsi Method" with the estimated relative error of 0.000001 and upload the script file. Direction: 1) Please submit"script file", NOT "function file". If you submit a function file, I will assign ZERO score. 2) You can find some matlab code for the Regula Falsi Method on a web or some books. You can use any code you can...

  • Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x...

    Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x = cos(w1*t) + cos(w2*t); where, w1=7; w2=23; t = [0:0.005:2] 2.   Plot the signal using sub plot a.   in time domain b.   in frequency domain 3)   Sample the signal under different sampling conditions: a.      Ts<1/2fm b.      Ts=1/2fm c.       Ts>1/2fm 4).      Multiple plot: the signal sampled under sampling condition and the signal x a.      in time domain b.      in frequency domain c.       Label and Title...

  • #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be...

    #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be specific. Use multiple comment lines if you need to #OR write code below the comments requesting code. #Make sure your file runs and generates the correct results. def main(): #define variable str1 with string "Hello" str1 = "Hello" #print out the 2nd letter print(str1[1]) #START QUIZ HERE print(str1[-2]) print(str1[:3]) print(str1[2:len(str1)-1]) str2 = "World" print(str1+str2) #write code below to iterate over the str1 and print...

  • ** Please provide a code in MATLAB ** 1. Write a function called taxcalculator that reads...

    ** Please provide a code in MATLAB ** 1. Write a function called taxcalculator that reads an amount in dollars, adds tax based on the table below and return the total with tax using elseif statement. 2. Write a function called printstars that reads the number of rows and returns a triangle of stars similar to the one below:       *      **     ***    ****   *****  ****** ******* ********

  • photo of the code please and an explnation if possible, Construct a simple MATLAB function program...

    photo of the code please and an explnation if possible, Construct a simple MATLAB function program my_factorial which calculates product of first n positive integer numbers (i.e. find factorial n!). For full points: - Make sure you protect the code from illogical use (n must be positive integer) - Test the function by comparing with built in MATLAB function factorial(n) - Make sure you test your function for any limitations. O marks) -3. Using my factorial function from the previous...

  • write a matlab code Write a MATLAB function to check the stability of a digital filter...

    write a matlab code Write a MATLAB function to check the stability of a digital filter described by its coefficients. Syntax: stable (b, a); where b and a are the system's forward and backward coefficient. Hint: The roots() function might be useful. Returned value: None. Operation: Displays either 'Stable' or 'Not Stable' message and plots the z-plane. Test with Case#1: y(n)= 2x (n) +x (n-1) +0.4y (n-1) - 0.6y (n-2) Case#2: y(n)= x(n) +0.5x (n-1) +2x (n-2)- y(n-1) +y (n-2)...

  • MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print...

    MATLAB Code: ?MATLAB Code: Write a function that converts a given letter grade it will print its equivalence in numerical scale. For example if the user enters A, then your function should print a message stating that the grade must be between 90 and 100. B is between 80 and 89, etc. Everything under 60 is F. Use the switch-case function. Use fprintf to display the results on the screen.

  • Please write code using MATLAB (4pts) Use the limit function to compute the following limits a)...

    Please write code using MATLAB (4pts) Use the limit function to compute the following limits a) lim b) compute the limit lim-, vIn! a*-1 d) compute the limit lim c) lim xsin (use the factorial function in 'b')

  • in MATLAB code/syntax please 3) (Chap 7 problem) Write a function newwords that will receive a...

    in MATLAB code/syntax please 3) (Chap 7 problem) Write a function newwords that will receive a word in a character vector as an input argument. It will then randomly scramble the letters and return the result. Here is an example of calling the function: >> newwords ('exceptional) ans 'tponexlicae

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