0
$\begingroup$

Sinc(10.t) Function and Amplitude Spectrum in the Frequency DomainFirst of all, hello.

This question is about a problem that I’ve faced during an attempt to obtain both time and frequency responses of a sinc function in MATLAB. The problem is an inconsistency between my calculations that I’ve done on the paper and simulation results that I’ve observed in MATLAB.

I’ve picked up $sinc(10 \cdot t)$ function and at first, I’ve taken its Fourier transform on paper. Afterwards, in order to have an experience in coding, I implemented this operation into MATLAB and plotted the functions both in the time and frequency domains.

However, in the amplitude spectrum in the frequency domain, the amplitude of the resultant rectangular pulse didn’t match with my results on the paper. According to my analysis results, the amplitude of the rectangular pulse is 0.1 but in MATLAB, I’ve got 10 instead of it.

My MATLAB code for simulation is given below:

t = -10: 0.01: 10; 
Ts = 0.01;  % Sampling period in seconds
fs = 100;  % Sampling frequency in Hertz
function_1 = sinc(10 * t);  
number_of_samples_1 = length(function_1);
number_of_samples_2 = power(2, nextpow2(number_of_samples_1));
f = linspace(-fs / 2, fs / 2, number_of_samples_2);   
function_2 = fft(function_1, number_of_samples_2);
function_3 = fftshift(function_2);
function_4 = abs(function_3);
subplot(2, 1, 1);
plot(t, function_1, "r");
xlabel("Time (s)");
ylabel("Function-1 (t)");
title("Sinc(10.t) Function in the Time Domain");
subplot(2, 1, 2);
plot(f, function_4, "r");
xlabel("Frequency (Hz)");
ylabel("|Function-4 (f)|");
title("Amplitude Spectrum of Sinc(10.t) Function in the Frequency Domain");

My question is this: Why has this result occurred in contrast to my expectations and analysis?

I will be happy if you give feedback to my problem and question.

Thank you.

$\endgroup$
2
  • 1
    $\begingroup$ This answer should help you understand what's going on. $\endgroup$
    – Matt L.
    Mar 16, 2021 at 11:20
  • $\begingroup$ @Matt L. Okay, I understood now. I wish I had a technology that computes in continuous time rather than algorithms which are dealing with individual elements. Thank you. $\endgroup$ Mar 16, 2021 at 19:02

2 Answers 2

1
$\begingroup$

I have recently answered a related question.

What happens is that MATLAB fft is calculating a sum in the sampled points, the integral would be approximated with a (Riemann) sum.

$$ \int_{0}^{T} f(x)dx \approx \sum_{k=0}^{N-1} x(k \Delta t) \Delta t$$

The $\Delta t=0.01$ factor matches the two results.

$\endgroup$
0
$\begingroup$

For an N-point FFT the frequency-domain real-valued zero Hz (DC) bin value will be the sum of your N sinc input samples. The sum of your N = 2001 sinc input samples is 9.9799. However, you didn’t compute a 2001-point FFT. You computed a 2048-point FFT so your computed zero Hz (DC) bin value will be slightly different than the expected 9.9799.

$\endgroup$
4
  • 1
    $\begingroup$ I thought that even with zero padding the 0 Hz bin will still be the sum of all the samples? The DFT formula is still just the sum if we're not normalizing by the number of samples. $\endgroup$ Mar 16, 2021 at 13:34
  • 1
    $\begingroup$ Hi Dan. With zero padding I "zoomed in" on the OP's freq plot and found the magnitude at 0 Hz to be equal to 10.00 rather than the expected 9.9799. After reading your comment I plotted his |function_4| using dots rather than straight lines and found the first magnitude sample of the |function_2| to reside just slightly greater than 0 Hz in his |function_4| plot. And that first magnitude sample of the |function_2| sequence is indeed 9.9799, as you suspect. There IS no sample at 0 Hz in his |function_4| plot! This is why we should plot spectral samples using dots rather than straight lines. $\endgroup$ Mar 17, 2021 at 18:42
  • $\begingroup$ thanks Richard, making sure I wasn’t missing something which would typically be the case $\endgroup$ Mar 17, 2021 at 19:09
  • $\begingroup$ Hi Dan. It wasn't you, it was I who missed something :-) $\endgroup$ Mar 17, 2021 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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