2

In order to design a filter (windowing method), I first generate my sinc function, like so:

L = 20;
fc = 0.25;
n = (1:L)';
my_sinc = sin(2*pi*fc*(n-L/2)) ./ (pi*(n-L/2));            
my_sinc(L/2) = 2*fc;

Then I apply window:

win = blackman(L, 'symmetric');
filter_coeffs = (my_sinc .* win);

Can the first step be done using Matlab's builtin sinc() function?

Danijel
  • 8,198
  • 18
  • 69
  • 133

1 Answers1

3

Absolutely. You can use the builtin sinc function to get exactly the same result as what you have calculated in my_sinc. Since sinc(x) = sin(pi*x)/(pi*x), in your case the input argument to the sin function, x, is equal to 2*pi*fc*(n-L/2). The denominator can then be written as a function of this x (pi*(n-L/2) = 0.5*x/fc) which gives you a scaling factor of 2*fc multiplying the sinc. This can be illustrated here:

builtin_sinc = 2*fc*sinc(2*fc*(n-L/2));
hold off; stem(n, my_sinc);
hold on;  plot(n, builtin_sinc, 'rx');

enter image description here

You can then subsequently obtain the same filter coefficients with

filter_coeffs = (builtin_sinc .* win);

or directly

filter_coeffs = 0.5*sinc(2*fc*(n-L/2)) .* win;
SleuthEye
  • 14,379
  • 2
  • 32
  • 61
  • Thanks. Here is a basic theory behind `sinc`: [Ideal Lowpass Filter](https://ccrma.stanford.edu/~jos/sasp/Ideal_Lowpass_Filter.html). – Danijel Mar 20 '18 at 12:51