Thread Subject: Using fft function

Subject: Using fft function

From: Timothy

Date: 4 Nov, 2009 16:42:03

Message: 1 of 5

I am trying to plot a fft spectrum for a stairs signal. For example:

time = 1:36;
mag = [1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0 1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0];
stairs(time, mag)

Question is how do I use this signal to create an fft spectrum? Any leads will be greatly appreciate.

Subject: Using fft function

From: Luca Zanotti Fragonara

Date: 4 Nov, 2009 17:26:03

Message: 2 of 5

"Timothy " <timothya@haywardtyler.com> wrote in message <hcsasr$e80$1@fred.mathworks.com>...
> I am trying to plot a fft spectrum for a stairs signal. For example:
>
> time = 1:36;
> mag = [1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0 1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0];
> stairs(time, mag)
>
> Question is how do I use this signal to create an fft spectrum? Any leads will be greatly appreciate.


using the fft command?

Subject: Using fft function

From: TideMan

Date: 4 Nov, 2009 19:18:55

Message: 3 of 5

On Nov 5, 5:42 am, "Timothy " <timot...@haywardtyler.com> wrote:
> I am trying to plot a fft spectrum for a stairs signal. For example:
>
> time = 1:36;
> mag = [1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0 1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0];
> stairs(time, mag)
>
> Question is how do I use this signal to create an fft spectrum? Any leads will be greatly appreciate.

But fft won't see it as a stairs signal.
What it will see is:
plot(t,mag,'o')
For the stairs signal, you have two data points at each time stamp.
But fft requires data that are equispaced in time.

Subject: Using fft function

From: Timothy

Date: 5 Nov, 2009 08:22:02

Message: 4 of 5

TideMan <mulgor@gmail.com> wrote in message <f074b9d6-8740-4fc2-bbb2-ba8dac9ba2bd@y10g2000prg.googlegroups.com>...
> On Nov 5, 5:42?am, "Timothy " <timot...@haywardtyler.com> wrote:
> > I am trying to plot a fft spectrum for a stairs signal. For example:
> >
> > time = 1:36;
> > mag = [1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0 1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0];
> > stairs(time, mag)
> >
> > Question is how do I use this signal to create an fft spectrum? Any leads will be greatly appreciate.
>
> But fft won't see it as a stairs signal.
> What it will see is:
> plot(t,mag,'o')
> For the stairs signal, you have two data points at each time stamp.
> But fft requires data that are equispaced in time.
>

Thank you for the reply. I was expecting Matlab to know how to calculate the fft for this signal, but I realised it is not straight forward. Do you have any way around this?

Subject: Using fft function

From: TideMan

Date: 5 Nov, 2009 19:15:12

Message: 5 of 5

On Nov 5, 9:22 pm, "Timothy " <timot...@haywardtyler.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <f074b9d6-8740-4fc2-bbb2-ba8dac9ba...@y10g2000prg.googlegroups.com>...
> > On Nov 5, 5:42?am, "Timothy " <timot...@haywardtyler.com> wrote:
> > > I am trying to plot a fft spectrum for a stairs signal. For example:
>
> > > time = 1:36;
> > > mag = [1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0 1 2 3 4 5 6 6 6 6 6 5 4 3 2 1 0 0 0];
> > > stairs(time, mag)
>
> > > Question is how do I use this signal to create an fft spectrum? Any leads will be greatly appreciate.
>
> > But fft won't see it as a stairs signal.
> > What it will see is:
> > plot(t,mag,'o')
> > For the stairs signal, you have two data points at each time stamp.
> > But fft requires data that are equispaced in time.
>
> Thank you for the reply. I was expecting Matlab to know how to calculate the fft for this signal, but I realised it is not straight forward. Do you have any way around this?

Why would you expect Matlab to know how to do such a thing?
The FFT is an algorithm that operates on equispaced time series data,
where time is monotonically increasing.
But you want to transform data in which time is not monotonically
increasing, so the FFT doesn't work, no matter which package you use:
Fortran, C++, Python, whatever.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com