Error in using fir1() function
5 ビュー (過去 30 日間)
古いコメントを表示
I have written the following code for an FIR filter design.
clc;
close all;
clear all;
fp=input('enter the pass band frequency:');
fs=input('enter the stop band frequency:');
rp=input('enter the pass band attenuation:');
rs=input('enter the stop band attenuation:');
f=input('enter the sampling frequency:');
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n=abs(n);
wp=-2*fp/f;
ws=-2*fs/f;
wn=(ws+wp)/2;
if(rem(n,2)==0)
m=n+1;
else
m=n;
n=n-1;
end
w=hann(m);
b=fir1(n,wn,w);
freqz(b,1,500,3000);
title('magnitude and phase response');
During execution, the following values for the input are provided:
enter the pass band frequency:1000
enter the stop band frequency:1200
enter the pass band attenuation:0.2
enter the stop band attenuation:45
enter the sampling frequency:3000
The error displayed after entering the values is:
??? Error using ==> fir1 at 77 Frequencies must fall in range between 0 and 1.
Error in ==> hanning1 at 35 b=fir1(n,wn,w);
Please help in resolving the error.
0 件のコメント
採用された回答
Wayne King
2012 年 4 月 4 日
Why are you putting - signs on these:
wp=-2*fp/f;
ws=-2*fs/f;
Take out the - signs.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Digital Filter Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!