Say I have a signal:
[1, 1 , 1; 1 100 1; 1 1 1];,
- I wanted its frequency response, then can I take its FFT?
- Why does MATLAB have two functions to do the same thing,
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.Sign up to join this community
Yes for 2D signals you can take a 2D fft, and if the 2D signal is represented in the time domain, then its fft is represented in the frequency domain. 2D FFT's have many other interesting applications, for example image creation in synthetic aperture radar (SAR), where an inverse 2D FFT of radar reflections results in the creation of an image.
If your interest is in the frequency response, then you most likely want a continuous function of frequency, which would be the Discrete Time Fourier Transform, as opposed to the Discrete Fourier Transform (which the FFT computes) which is a discrete function of frequency. freqz returns samples of the DTFT, while fft returns samples of the DFT.
The fft (and fft2) is an algorithm that implements the Discrete Fourier Transform (DFT), while freqz (and freqz2) is an algorithm that returns samples of the Discrete Time Fourier Tranform (DTFT). The DFT is a discrete function in frequency while the DTFT is a continuous function in frequency.
Below are some graphics that will help illustrate the difference between the DFT and DTFT, as well as show for reference the Fourier Transform from the continuous time domain (The CTFT).
A key take-away to see from these and waveforms in general whether they be time or frequency domain waveforms, is that if a waveform is repeating in one domain, it must be discrete in the other domain. (Or stated another way if a waveform is continuous in one domain, it must not be repeating in the other). Pay attention to this relationship as you review the plots below. And this relationship really helps see the difference between the DFT and DTFT. Another example some may be familiar with is sampling in the time domain ---- this is a repeating function in the frequency domain (called aliases), which is why we only need to concern ourselves with the frequency response from $-f_s/2$ to $+f_s/2$ where $f_s$ is the sampling rate; to bridge the analog and frequency domain worlds I like to still view the digital frequency domain as extending to infinity, but knowing that everything beyond $f_s/2$ keeps repeating. This has been a helpful intuitive view for me when dealing with multi-rate processing, or when going from Analog to Digital with undersampling etc... I have other posts that dive into that path in more detail, but specific to CTFT, DTFT and DFT:
First the CTFT. Notice that it extends in time from minus infinity to plus infinity (even if the waveform itself is zero). There is no implied repetition in time, therefore the frequency domain is a continuous function. The frequency domain also goes from minus infinity to infinity, with no implied repetition, so the time domain is also continuous.
With the DTFT, the only difference from above is we now sample in time the non-repeating time domain function. This one change causes the frequency domain to repeat. But notice that the frequency domain is a continuous function. (Because the time domain is not repeating).
Now finally the DFT, in this case we limit the time domain over a finite duration (similar to the Fourier Series Expansion), which I argue is identical (mathematically and intuitively) to repeating in time, as evidenced by the frequency domain becoming discrete (and the frequency domain is repeating as well for the same reason). This detail may require further explanation than i am giving here; for further details on the implied repetition please see my other post at this link:
Regarding practical uses for the DTFT, which the freqz command implements: The freqz command is used to plot the frequency response for digital transfer functions. In this case we are interested in a continuous function in frequency, as the system can take any value frequency (even though it is a sampled system) at its input within its allowed Nyquist range. If you didn't use the freqz command, you can emulate it's effect with zero padding. Reviewing the plot of the DTFT above should illuminate how zero padding can approximate the DTFT (for the "real" DTFT you would have to pad to infinity!). This also shows clearly why zero padding results in interpolating more samples in the frequency waveform (without changing the underlying waveform itself). If we add twice as many samples by adding zeros in the time domain equal to the number of original time domain samples, we end up with additional samples in the frequency domain, except each new sample will be in between the original frequency domain samples (interpolated)--- as we add more zeros we get more samples in between, approaching a continuous function in frequency.