Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help with fft and red noise

Subject: Help with fft and red noise

From: James Hickey

Date: 9 Nov, 2010 16:09:05

Message: 1 of 5


Hi,

I am new to Matlab and would like some help on how I would create a red noise spectrum.

I need it in order to compare it to a frequency analysis I have created using fft which I believe represents a certain amount of red noise.

Basically, what I would like is some code that will create an array (I think) of red noise that I can plot onto the same axis as my fft output.

Thanks in advance.

James.

Subject: Help with fft and red noise

From: Wayne King

Date: 9 Nov, 2010 17:30:24

Message: 2 of 5

"James Hickey" <jameshickey77@googlemail.com> wrote in message <ibbrn0$h4c$1@fred.mathworks.com>...
>
> Hi,
>
> I am new to Matlab and would like some help on how I would create a red noise spectrum.
>
> I need it in order to compare it to a frequency analysis I have created using fft which I believe represents a certain amount of red noise.
>
> Basically, what I would like is some code that will create an array (I think) of red noise that I can plot onto the same axis as my fft output.
>
> Thanks in advance.
>
> James.

Hi James, Red noise is typically used to describe an AR(1) process that is lowpass in nature, meaning that the single pole is near 1+j0 on the unit circle. So if you create an AR(1) filter with something like:

 A = [1 -0.9];

and then filter white noise with this single-pole IIR filter:

x = filter(1,A,randn(1000,1));

You get a process which has a red-noise type behavior.

Hope that helps,
Wayne

Subject: Help with fft and red noise

From: James Hickey

Date: 9 Nov, 2010 18:06:04

Message: 3 of 5

Cheers Wayne. That's great. Is there any way to force the red noise between certain values though?

For example, the data I wish to compare it to varies between 0 and 0.2 but the red noise produced varies between anything from 10 to -10.

Thanks,

James.

Subject: Help with fft and red noise

From: Wayne King

Date: 9 Nov, 2010 19:13:04

Message: 4 of 5

"James Hickey" <jameshickey77@googlemail.com> wrote in message <ibc2ic$mka$1@fred.mathworks.com>...
> Cheers Wayne. That's great. Is there any way to force the red noise between certain values though?
>
> For example, the data I wish to compare it to varies between 0 and 0.2 but the red noise produced varies between anything from 10 to -10.
>
> Thanks,
>
> James.

Hi James, Yes you can. What you need to know is:

The variance of the AR(1) process: This is (I really wish I could type in TeX here):

sigma^2/(1-phi^2)

where sigma^2 is the variance of your white noise input and phi is your AR(1) coefficient (0.9 in my example).

Remember that for a Gaussian process the total range will be the mean +/- approx. 3 standard deviations. When you say it varies between [0,0.2] I'm going to take the mean value to be 0.1 so that means that 3*sigma is approximately 0.1.

This means sigma is approximately 0.0333. That value squared is the variance of the AR(1) process. Now to get the variance of the white noise input you multiply 0.0011*(1-0.9^2). So

x = sqrt(2.09e-4)*randn(1000,1);
y = filter(1,A,x)+0.1;

Should give you a process that varies from about [0,0.2] and has an AR(1) power spectral density.

Wayne

Subject: Help with fft and red noise

From: James Hickey

Date: 9 Nov, 2010 23:35:04

Message: 5 of 5

That's perfect! Thanks!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us