# Upsampling and comb function

Could somebody explain how upsampling works with comb function. How comb function looks for upsampling process? (if it possible I would appreciate if answer would be related to DFT)

• If you mean by upsampling that you sample in higher rate or interpolation. Comb function does not seem to be really relevant for the DFT case. Upsampling of a signal usually allow you to look into higher frequencies - relates to the sampling rate. Interpolation, depending how you do it provides an insight of potential behavior and interpretation of the signal under certain assumption - so it contributes to the analysis but does not generate more data than what initially accumulated. – Moti Jul 13 '16 at 19:21

If with "Comb Function" you are referring to the periodicity of the spectrum of a sampled signal, first see Intuition for sidelobes in FFT for further details on the unfolded view of a digital spectrum (specifically how it repeats over the range of 0 to $F_s$ where $F_s$ is the sampling rate.)

(If you are referring to the use of "Comb Filters" then see this explanation of the CIC Decimator: Fast Integer 8 Hz 2nd Order LP for Microcontroller, and I can elaborate upon request on the CIC Interpolator which has a similar structure).

Upsampling and interpolation in general can be viewed as diagrammed in the figure below (once understanding the unfolded view of the digital spectrum from the top link above).

The frequency is upsampled by a factor of M by inserting M-1 zeros. In the case of the example in the figure, 3 zeros are inserted between every digital sample to increase the sampling rate by a factor of 4.

What happens when we do the zero insert is we get our original spectrum intact, along with new frequency components (replicas of our original spectrum) that now exist in our primary digital frequency span of $0$ to $F_s$. These are the exact same components that existed adjacent to all multiples of the sampling rate as described above in the unfolded view of the digital spectrum. If we can create a digital filter (Interpolation FIR or IFIR) that will pass the signal of interest with no distortion, and completely eliminate the unwanted components that would otherwise be distortion, as shown in the figure below, we will have a perfect interpolation between the original samples (the filter will grow the zero values to the perfect interpolation value needed, by nature of having all distortion frequencies eliminated while not distorting our spectrum of interest). Of course such an ideal filter is not realizable, but we can control and decide on how good of an interpolation we want based on the complexity (number of taps) in our filter design. Also one may ask why the zero insert, why not do a first order hold (meaning use the current value as the value to insert instead of inserting zeros)?

To demonstrate the considerations with this, consider that a zero order hold is done mathematically in the time domain by convolving our waveform with a digital "pulse", while a zero insert is done by convolving our waveform with a digital "impulse".  Convolution in the time domain is multiplication in the frequency domain, so to explain using analog terms which the digital system will approximate- for the case of a first order hold, we are multiplying our desired frequency response by a sinc function (FT of a pulse) leading to passband droop, but for the zero insert, we are multiplying our desired frequency response by a constant (FT of an impulse), leaving our original passband undistorted. The plots below demonstrate this for our intepolate by 4 example with the exact digital solution of what would occur.  Convolving with the digital equivalent of a sinc function is not a terrible way to go, and in fact its nulls will be right in the center of the frequency bands we want to suppress (very convenient). It is just important to understand the implications of passband droop and how to compensate for that if you take that approach (see how to make CIC compensation filter for a very simple 3 tap "inverse Sinc" compensation approach I have used). The CIC Interpolator is in fact such a "first-order hold" interpolation method that is very popular because of its simplicity. Otherwise is absolute minimum distortion of your original waveform over its full usable bandwidth is important then zero-insert with a good filter design based on defined passband and stop band requirements is the way to go. Filter design is optimized by only rejecting the bands where the spectrum is replicated. Matlab's firls and firpm filter commands (Least Squared and Parks-McCLellan) both support creating multi-band filters which are perfect for this purpose. Further, if you go down the path of zero insert and optimum filter design, the end result can be implemented efficiently as a polyphase interpolator as shown in the figure below. The process is to design the filter as described above, and then map the same coefficients into the polyphase structure as shown in the figure. The figure is descriptive of the mapping process in showing only 8 taps, but of course with only 8 taps in the original filter you cannot expect very good performance. An actual interpolate by 4 filter may have 64 taps for example, leading to 4 polyphase filters each with 16 taps, mapped the same way from the original base filter to the polyphase structure. The more taps the better the base filter can minimize pass band ripple and maximize the stop band rejections.  The reason for this mapping is very clear by following what occurs with the zeros that were inserted in the original filter- they mask several coefficients that are not needed on any particular given cycle (see figure below): 