Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just got a thought when generating matrices , plotting it and taking its FFT,

Lets say, I have randomly input a matrix of length 256,

[1 7 9 5 7 1 -2 0..................8]

According to the FFT, the resulting 256 FFT coefficients correspond to the following frequencies:

0, $f_s/256$, $2 f_s/256$, $3 f_s/256$, $\ldots$, $255 f_s/256$

but since the samples i taken has no sampling frequency defined how could there be some sampling frequency ? Like in an image ,

Since the image is just a 2 dimensional Matrix , if i randomly generate an image in a matlab with random pixel values (sample points) and plot its FFT , the matlab will show the frequencies of that 2-D matrix but since there is no Sampling Frequency is defined how matlab calculates the frequency for each of the coefficient ?

share|improve this question
up vote 2 down vote accepted

Units can be arbitrary, such as ISO Meters, or the length of the current king's foot (maybe longer than last year after the assassination of some shorter king).

A good default unit if there isn't some ISO standard, useful natural unit, or you can't think of one to make up (how long is your monitor's display, or your left foot, etc.), is the length of your window of data. e.g. 1 cycle per your vector of 256, 2 cycles, 3 cycles, etc. per your vector length. If your vector displays as 3 inches long on your display, then you can also easily convert cycles/vec into cycles/inch, or per/mm, per/fortnight, etc.

share|improve this answer

If your input data does not correspond to regularly-spaced samples, I would argue that it makes no sense to compute the Fourier transform. Garbage in, garbage out.

If your matrix corresponds to an image, then it most likely does consist of regularly spaced samples, and so a sampling frequency is defined.

share|improve this answer

Looks like you are generating your signal programmatically. I have done the same at my job a lot of times, with the specific goal of performing FFT analysis.

The fact is: YOU must specify, arbitrarily, what is the sampling frequency, which you are supposed to already know. If the signal is synthetic, you can use any convenient value.

For example, I want to simulate 10 seconds of electromyogram signal (which is my actual field of application). I can take some magic function and use it to generate the desired signal. Since my ACTUAL sampling rate is 2 kHz, then I must "tell" the function to generate a signal with 20,000 samples.

When I take this signal and use it as an imput with some FFT function, one of the function parameters is the sampling rate.

Now suppose I have geological, or astronomical data. If I want to simulate large time scale events, I can tell my sampling interval is an year, or even a century. The input might even be the same array, but if you tell your FFT function that the sampling rate is R, then your output frequencies will be proportionally related to R. Sampling rate, in this case, is metadata, is independent of the signal, it is not "contained" in an array, which is just a sequence of values. It is only your pre-existent knowledge about the signal's nature that allows you to tell which is its sampling rate.

Hope this helps!

share|improve this answer

Matlab doesn't need to know a specific sampling frequency in order to implement the DFT/FFT. This comes from the definition of the forward DFT for a discrete-time signal (DT), $x[n]$, with $N$ entries (i.e. of finite length),

$$X_k = \sum_{n=0}^{N-1} x[n] e ^{-j 2 \pi \frac{kn}{N}}.$$

This definition does not make any use of the concept of a "sampling frequency". While it is common that a DT signal is generated by sampling a continuous time (CT) signal, many discrete signals do not have such an origin. Specifically, the "frequencies" of the DFT are references to periodicity within the samples according to the length of the DT signal. Take a look at the complex sinusoid used in the DFT: $$ e^{-j 2 \pi \frac{k}{N} n} = \cos(2 \pi \frac{k}{N}n) - j \sin(2 \pi \frac{k}{N}n) = \cos(\omega_k n) - j \sin(\omega_k n)$$ where $\omega_k = 2 \pi \frac{k}{N}$ is dependent upon which frequency coefficient ($X_k$) you are solving for and the length of the signal ($N$). So, we see that the DFT computes a discrete number of frequency coefficients, where the maximum number of frequency coefficients which can be calculated is dependent upon the number entries in our original, finite length signal ($x[n]$), i.e. the frequencies

$$0,\frac{2 \pi}{N}, \frac{4 \pi}{N}, \frac{6 \pi}{N}, ..., \frac{2 \pi (N-1)}{N}.$$

In other words, the frequencies calculated using the DFT/FFT have to do with regularity at certain ratios of the signal length. So, regularities every one sample, two samples, three samples, etc.

Also, keep in mind that coefficients produced by the DFT/FFT are periodic, so when you view the DFT/FFT coefficients, as in Matlab, you are only observing a single period (or "replica") of the true spectrum. For more information on this, I would suggest reading up on, or asking about, the relationship between the DFT and the Discrete Time Fourier Transform (DTFT), which produces a continuous function of frequency for a set of discrete time entries.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.