Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate white noise with amplitude between [-1 1] with Matlab

I'm using the Matlab function Y = WGN(M,N,P) to generate white noise with Gaussian distribution. This function uses a power value (dB Watts) to calculate the amplitude of the output signal. Since I want to get an output amplitude range of -1 V to 1 V there is a function mode 'linear'.

I'm trying to use the 'linear' mode to produce the output but the result is an output amplitude range of [-4 4]

RandomSignal = wgn(10000,1,1,1,'linear');
Time = linspace(0,10,10000);
figure()
plot(Time,RandomSignal)

figure()
hist(RandomSignal,100) 

Is there another function to produce this result, or am I just doing something wrong?

like image 489
PVaz Avatar asked Dec 17 '25 03:12

PVaz


1 Answers

As others have said, you can't limit a Gaussian distribution. What you can do is define your range to be 6 standard deviations, and then use randn(m,sigma) to generate your signal.

For example if you want a range of [-1 1] you will choose sigma=2/6=0.333 and Mu=0. This will create a chance of 99.7% to be inside the range. You can then round up and down those numbers that are out of the range.

This will not be a pure Gaussian distribution, but this is the closest you can get.

like image 130
BioSP Avatar answered Dec 19 '25 20:12

BioSP