Error in using fir1() function
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Wayne King
am 4 Apr. 2012
Why are you putting - signs on these:
wp=-2*fp/f;
ws=-2*fs/f;
Take out the - signs.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!