Error in using fir1() function

5 visualizaciones (últimos 30 días)
Arnab Ray
Arnab Ray el 4 de Abr. de 2012
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.

Respuesta aceptada

Wayne King
Wayne King el 4 de Abr. de 2012
Why are you putting - signs on these:
wp=-2*fp/f;
ws=-2*fs/f;
Take out the - signs.
  1 comentario
Arnab Ray
Arnab Ray el 4 de Abr. de 2012
Thank you for solving. The problem has been resolved.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by