Window Design of Digital Filters

조회 수: 3 (최근 30일)
Kamal Premaratne
Kamal Premaratne 2020년 4월 14일
댓글: Star Strider 2020년 4월 14일
Hi. I am calling the fir1 function to design an FIR filter. One argument of fir1 is the type of window that is to be used, e.g., hann, hamming, etc. However, the type of window depends on the stopband attentuation that one requires. So, I have an if ... else ... end conditional prior to callng fir1. it looks like
if deltadB_max <= 21
FixedWindow = 'rectwin';
else
FixedWindow = 'bartlett';
end
Now, when I invoke fir1, how can pass the variable FixedWindow into the arguments of fir1? Thank you.

채택된 답변

Star Strider
Star Strider 2020년 4월 14일
Both the rectwin and bartlett functions have a single length argument. That simplifies this considerably.
if deltadB_max <= 21
FixedWindow = @(L) rectwin(L);
else
FixedWindow = @(L) bartlett(L);
end
L = 35;
b = fir1(34,0.48,FixedWindow(L)); % Test Design
freqz(b,1)
That ran without error and gave the appropriate result when I ran it (R2020a) with different values for ‘deltadB_max’.
For windows that require more parameters or different parameters, this would need to be changed appropriately. I leave that to you.
.
  댓글 수: 2
Kamal Premaratne
Kamal Premaratne 2020년 4월 14일
Fantastic. Works like a charm. Thank you so very much. I guess I now do appreciate the fact that all the window functions have one argument. I'll have to look into it when I am done with solving these problems. Thanks again.
Star Strider
Star Strider 2020년 4월 14일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Floating-Point to Fixed-Point Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by