# Signal generation: random noise

I have attempted question 1 a) below in MATLAB 6.5, but I need my answer to be checked.

• How do I do question 1 b) below ?
• What does it mean to have a zero mean?
1. Generate the following signals with a computer program:
• a) Random noise in the amplitude interval (0,0 1,0)
• b) Random noise in the previous question but with a zero mean
function [] = Question1a()
datapoint = 1000;
t=0:1/datapoint:2;
x=sin(2*pi*5*t);
y=sin(2*pi*25*t);
z= x + y;
NoiseAmplitude = 1;
Noise = x + NoiseAmplitude*randn(size(z));
plot(t,Noise);
title('Noise in the Amplitude interval (0,0,1,0)')
ylabel ('Amplitude')
xlabel ('Time(s)')

• Why are you adding a sinusoid to your pseudo-random sequence? Sep 23 '16 at 9:11
• @Speedy, I was following some examples from past questions on this site and on other sites on the web. I want to know the best way to tackle this problem. thank you.
– joe
Sep 23 '16 at 10:15

The phrase "zero mean" is primarily a phrase from the mathematical field of statistics. For us, a "zero mean" sequence means a sequence of numbers whose mathematical average is zero.

By the way, MATLAB's randn(1,N) command does not generate exactly a zero mean sequence. It generates an N-length sequence of random numbers that fluctuate randomly above and below an amplitude of zero, but the sequence's mean is not guaranteed to be zero. The larger is N the closer the average (mean) of randn(1,N) will be to zero. Try these:

mean(randn(1,5)) and mean(randn(1,500))

I have no idea what "the amplitude interval (0,0 1,0)" means.

• Thanks Richard. So this means my answer is incorrect?
– joe
Sep 23 '16 at 4:10
• @joe: I don't know if your solution is correct because I don't understand the original problem. Can you tell me what "in the amplitude interval (0,0 1,0)" means in English words? [In your code, it looks like you didn't need to compute the 'y' and 'z' sequences.] Sep 23 '16 at 20:37
• I asked my lecturer early today and he said we have to take any sinusoidal of our choice at a frequency of our choice and we have to add noise to the signal. He said the amplitude of the noise must be 1. So i think I complicated stuff and used 2 sinusoidal waves and summed them up, since I followed an example from another website were they used 2 waves. He also told us we can use "Rand" or "Randn" and for the second part of the question we use "mean". He also told us we can use another software if we not sure of MatLab or Octave. He also said we have to had him the plots on Tuesday.
– joe
Sep 23 '16 at 21:30
• @joe: Our conversation here is too complicated to conduct on this web page. Send me a private e-mail and I will help you. (For me right now, it's 2:24 AM on Saturday morning.) My e-mail address is: R_dot_Lyons_at_ieee_dot_org. Sep 24 '16 at 9:26
• Sir, I did email you. thank you. Its 3:15 PM Saturday evening in my country.
– joe
Sep 24 '16 at 13:14