I have this code: nfilt=128; wnm=[cLw cHi]/15000; bm = fir1(nfilt,wnm); y_filteredm=filter(bm,1,data);
for the values wnm =[0.533300000000000 1] I get bm = NaN and for wnm = [0.844444444444445 1.00000000000000] I get the error "Frequencies must fall in range between 0 and 1." after I try to calculate bm. What did I do wrong?

답변 (2개)

Honglei Chen
Honglei Chen 2014년 11월 13일

0 개 추천

Did you compute wnm from some other functions? This looks like a round off numeric issue. A simple fix could be adding the following line before you invoke fir1
wnm(wnm>1)=1
Ges1234
Ges1234 2014년 11월 14일

0 개 추천

Thanks for your answer. That helped me with the error, but bm is still NaN if the higher frequency is 1. So as a workaround I inserted wnm(wnm==1)=0.9999999; and that works fine. It just seems odd that fir1 can't handle 1 as the higher frequency. I calculated wnm with this equation: wnm=[lowFreq highFreq]/(Fs/2);

댓글 수: 1

Honglei Chen
Honglei Chen 2014년 11월 25일
The doc does say Wn needs to be between 0 and 1, not inclusive. You can also see it if you do
>> help fir1
HTH and sorry I didn't make that connection in my previous answer.

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2014년 11월 13일

댓글:

2014년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by