From: rajgerman on
Thanks guys I have understood the hamming window and also have implemented
it.

I'm having difficulty labelling my axis. I have converted the complex
numbers of ffted data (X) to real values by applying the conjugate (Z).

I'm having difficulty labelling and converting my x axis. I need to
represent it in frequency terms.

Data = Z
Sample rate = 44100Hz
Total no. of frequencies/values of data = 88200
Length of signal = 2 seconds

I have also applied fftshift to the data (Z) so that my left half is
negative and the right half is positive.

How can I represent the x-axis in frequency terms??

If someone could also tell me how I will be able to get rid of certain
frequencies e.g. I want everything below 20Hz to be cut off/throw it
away??
From: Fred Marshall on

"rajgerman" <rajgerman(a)msn.com> wrote in message
news:0eCdnVM_-79bTZzZRVn-pg(a)giganews.com...
> Thanks guys I have understood the hamming window and also have implemented
> it.
>
> I'm having difficulty labelling my axis. I have converted the complex
> numbers of ffted data (X) to real values by applying the conjugate (Z).

Why?

>
> I'm having difficulty labelling and converting my x axis. I need to
> represent it in frequency terms.
>
> Data = Z
> Sample rate = 44100Hz
> Total no. of frequencies/values of data = 88200
> Length of signal = 2 seconds

Each frequency value is 1/(Length of signal) apart = 1/2 Hz.
This is also understood from sample rate 44100 divided by number of values
88200 =
44100Hz / 88200samples = 0.5Hz/sample
Actually, because things are sampled I try to keep track by understanding
"data points or samples" AND "intervals"

So, 44100 sample rate for 2 seconds starts at time=0 and ends at time =
(2-1/44100).
There are 44100-1 intervals in between but normal assumptions add an
interval after the last sample (and then the sequence is assumed to repeat).
So, then there are 44100 intervals that encompass 2 seconds.

>
> I have also applied fftshift to the data (Z) so that my left half is
> negative and the right half is positive.

Why? The normal representation is from zero to fs/2 and from fs-fs/2 to fs
which is the same as from -fs/2 to zero. So it goes from zero to
fs-fs/(length of signal) and is assumed to repeat at fs with F(fs) = F(0).

>
> How can I represent the x-axis in frequency terms??
>

As above.

> If someone could also tell me how I will be able to get rid of certain
> frequencies e.g. I want everything below 20Hz to be cut off/throw it
> away??

High pass filter.
If you're doing it in the frequency domain then it's best to multiply by the
complex frequency response of an actual FIR filter - not just multiply by
zero where you want things to go away.

Fred


From: rajgerman on
Hey Fred

I didn't quite understand your explanation.

I applied fftshift so that it looks more simple. Now my data goes from -fs
to 0 and then from 0 to fs. I know that the negative half is just a mirror
image of the other side. All I need to know is how to represent the x-axis
in frequency terms?? What would be the coding??

Thanks for your help.

From: Fred Marshall on

"rajgerman" <rajgerman(a)msn.com> wrote in message
news:_sWdnTxyGJPA65nZnZ2dnUVZ_tWdnZ2d(a)giganews.com...
> Hey Fred
>
> I didn't quite understand your explanation.
>
> I applied fftshift so that it looks more simple. Now my data goes from -fs
> to 0 and then from 0 to fs. I know that the negative half is just a mirror
> image of the other side. All I need to know is how to represent the x-axis
> in frequency terms?? What would be the coding??

Do you mean you want someone to write the code for you?
I'll bet Google would result in a listing for you. Here's how it might go:

Make a vector that has the x values according to the frequency sample
spacing.

Spacing=1/T where T is the length of the signal ... that's what I tried to
tell you in my last post.

x(i)=(1/T)*(i-1)

Is that all you're asking?

As far as applying fftshift it's important to understand your objective. I
would not do it if I were just doing signal processing. However, if the
objective is to make "pretty pictures" then OK. Then you have to modify the
x vector from above of course but that's a very simple matter.

You may also consider repeating the value at fs/2 at each end so there are
N+1 samples in order to make the picture symmetrical around zero.

Examples:

If there are 100 samples going from zero to fs-1/T and you circularly shift
them by N/2 then the zeroeth sample will be at x2=51, the 100th sample will
be at x2=50 and the the 51st sample will be at x2=1 and the 50th sample will
be at x2=100. This isn't symmetrical. It looks like this:
x1(1) == 0
x1(2) == 1/T
x1(51) == fs/2
x1(100) == fs-1/T
repeats at x1(1) == fs....

Shifting by N/2 = 50:
x2(1) == fs/2
x2(51) == 0
x2(100) = fs/2-1/T
repeats at x2(1) == fs/2

So, you may wish to add another point just so it's symmetrical:
x2(101) == fs/2
and add the corresponding value to the y vector in the plot.

It that what you mean?

Now, if N is odd, then there won't be a value that corresponds to frequency
= fs/2 at all because fs/2 is not an integer multiple of 1/T. For N=101 you
will have:

x1(1) == 0
x1(2) == 1/T
..
x1(51) == fs/2 - 1/2T
x1(52) == fs/2 + 1/2T
..
x1(101) == fs - 1/T repeats at x1(1) == fs ....

Shifting by fs/2 corresponds to a shift of an odd integer multiple of 1/2T,
and causes the samples to align on odd intervals of 1/2T and we need a new
definition for x2 so I will define x3 to have 2*N samples = 202 samples. We
will get that by adding an extra samples in the x1 vector to get x1' and
adding zeros in the y value vector. Then you can shift by 101 samples:
Start with
x1'(1) == 0
x1'(2) == 1/2T with a zero value in the y values to be plotted
x1'(3) == 1/T
..
x1'(100) == fs/2- 1/2T .. which is an integer multiple of 1/T
x1'(101) == fs/2 with a zero value in the y values to be plotted
x1'(102) == fs/2 + 1/2T .. which is an integer multiple of 1/T
..
x1'(201) == fs - 1/T repeats at x1(1) == fs ....
x1'(202) == fs - 1/2T which is a sample added to fill in the array with a
zero value in the y values to be plotted

Now shift to get x3(103) == 0 ... this means a shift of 102:

x3(1) == fs/2 with a zero value in the y values to be plotted
..
x3(103) == 0
..
x3(202) = fs/2-1/2T
repeats at x3(1) == fs/2

So, you may wish to add another point just so it's symmetrical:
x2(203) == fs/2
and add the corresponding zero value to the y vector in the plot.

If I didn't make any mistakes then that's it.

Fred


First  |  Prev  | 
Pages: 1 2 3 4 5 6
Prev: Pulse shaping + interpolation
Next: FFT in OpenCV