2
votes

Let us suppose that we have signal

>> fs=100;

>> ts=1/fs;
>> t=0:ts:2.93;

>> x=23*sin(2*pi*30*t)+22*cos(2*pi*51*t)+24*sin(2*pi*15*t)+6*randn(size(t));

Because one frequency is high then sampling frequency divided by two, I want to apply low pass filter to that all frequency that are below 50 should stay unchanged, but all others should be removed, so I have tried:

>> fc=50;
>> wn=(2/fs)*fc;
>> b=fir1(20,wn,'low',kaiser(21,3));

but this command

fvtool(b,1,'fs',fs)

the generates error:

Coefficients must be finite.

Also the command

y = filter(b,1,x); removes all frequency components from  signal,what is problem?
1

1 Answers

3
votes

The coefficients in b are all NaN. This is because your cutoff frequency is set to 1, the Nyquist frequency, but according to the fir1 help:

The cut-off frequency Wn must be between 0 < Wn < 1.0, with 1.0 corresponding to half 
the sample rate.

There's no point to setting the cutoff to 1.0 with a low-pass filter since it would be designed to pass all frequencies.

Anyway, normalized frequencies go from 0 to fs/2, so if you want to pass below 50, your job is done since that's the Nyquist rate when the sampling rate is 100 Hz. Frequencies above 50 Hz cannot be represented in a discrete representation with a 100 Hz fs. Ideally you'd filter out high frequencies before discretization/sampling.