# Cut-off frequency not reached with my equiripple-filter

Asked by Jenny Eriksson on 13 Jun 2012
Latest activity Answered by Jenny Eriksson on 14 Jun 2012

Hi, I am new to filter design and I have designed an equiripple filter in matlab using the commands:

Hd=fdesign.lowpass('Fp,Fst,Ap,Ast',30000000,50000000,1,60,1000000000);

d=design(Hd,'equiripple');

With a passband frequency of 30MHz and a stopband frequency of 50MHz. However, when I filter the signal

x=1:100000;

y=2+sin(1000*x)+5*sin(1*10^9*x);

with the command

h=filter(d,y);

both sine-functions are reduced. But sin(100*x) should go through and I don't understand why it doesn't. Does anyone know what I am doing wrong?

Thanks Jenny

## Products

No products are associated with this question.

Answer by Wayne King on 14 Jun 2012

Hi Jenny, you don't tell me what Fs is here so I cannot say whether or not your design is correct.

Is Fs 10 kHz? in your time vector? if so then why are you stepping in increments of 1/(4*Fs)?? That changes the sampling rate. Your time increments have to be 1/Fs by definition.

```    Fs = 1e4;
t = 0:1/Fs:1-1/Fs;
y=sin(1000*2*pi*t)+cos(2*pi*250*t);
% design filter
Hd=fdesign.lowpass('Fp,Fst,Ap,Ast',500,700,0.5,60,10000);
d=design(Hd,'equiripple');
out = filter(d,y);
outdft = fft(out);
plot(abs(outdft))```

The sampling rate you use for the signal has to match the sampling rate used in the filter design.

Answer by Wayne King on 13 Jun 2012

I don't see that with your unit step time vector, your frequencies in

` y = 2+sin(1000*x)+5*sin(1e9*x) `

are appropriate. What frequency do you think sin(1000*x) is?

Your x vector has unit steps. If we translate this to your sampling frequency (used in your filter design) of 1 gigahertz, then these frequencies are aliased.

` f = 1000/(2*pi)`

Now with a unit step that means it has a period less than 1 sample. The period of sin(1000*x) is (2*pi)/1000. That's above the Nyquist considerably and therefore so is sin(10^9*x) even more so.

Why are you defining your signal like this? Why not use a time vector where you use the sampling interval that corresponds to your sampoing frequency?

```   Fs = 1e9;
t = 0:1/Fs:(1e5*(1/Fs))-(1/Fs); ```

I just set up t to be the same length as your original x.

Now define your sine waves over the t vector.

Answer by Jenny Eriksson on 14 Jun 2012

Thank you very much Wayne!

Your reply helped me generate a signal with the frequency I intended it to have, I didn't think about aliasing. However, when I create a signal (with the correct frequency), that should be damped, it's still there. So I wonder if I am still doing something wrong with the signal-generating. I decided to work with lower frequency levels (just to make it a bit easier) and I have generated a filter and a signal with the following commands:

Filter

```    Hd=fdesign.lowpass('Fp,Fst,Ap,Ast',500,700,0.5,60,10000);
d=design(Hd,'equiripple');```

Signal

```    t = 0:1/(4*Fs):(100*(1/(Fs)))-(1/(Fs));
y=sin(1000*2*pi*t);```

Then I filtered the signal using the command

`    h=filter(d,y);`

But I still see a signal with amplitude 1, shouldn't it be reduced since the 1000 Hz-signal is above the frequency stop of 700?