Question

Here is my Matlab/Octave program

clc;
close all;
%BPF of pass 400-600Hz
fs1=300;
fp1=400;
fp2=600;
fs2=700;
samp=1500;
ap=1;   %passband ripple
as=60;  %stopband attenuation
%Normalizing the frequency

wp=[fp1 fp2]/(samp);
ws=[fs1 fs2]/(samp);

[N,wn]=cheb1ord_test(wp,ws,ap,as); %Generates order  and cutoff parameters
[b,a]=cheby1(N,ap,wn); %Generates poles and zeros for the given order and cutoff

printf("b coeffs = %f\n",b);
printf("a coeffs = %f\n",a);

[H,W]=freqz(b,a,256); 
plot(W/(2*pi),20*log10(abs(H))) %Transfer function works correctly, so coefficients are correct

 %100 samples of 500hz
n = 1:100;  
 x=10*cos(2*pi*n*500*(1/samp)); 

printf("Order %d\n",N);    %Depends on required ripple attenuation
figure;

subplot (2,1,1); plot(x);

y=filter(b,a,x); %**Apparently i suspect this does not work**

subplot (2,1,2); plot(y);

When i see the magnitude/frequency response, the graph is perfect and indicates 400 and 600 to be my filter cutoffs.

But however when i apply an input signal of 500Hz, i must expect to see the signal pass through the filter unharmed (as observed when i used Butterworth function), but the output is distorted and almost contains no signal

So i infer that my mistake is using the filter function to combine the chebyshev coefficients with the input signal.

If this is the problem, then how do i apply chebyshev coefficients to an input digital signal ?

Was it helpful?

Solution

For cheb1ord and cheby1 the frequencies are normalized between 0 and 1 with 1 corresponding to half the sampling frequency. You should get your wp and ws using

wp=[fp1 fp2]/(samp/2);
ws=[fs1 fs2]/(samp/2);

where samp is your sampling frequency.

OTHER TIPS

I think the problem is with your x signal: I don't quite know what it is, but I can tell you what it is not and that's a 500Hz input signal.

I would define the time vector first and then apply the cos function (I assume you are sampling at 1500Hz):

f_input = 500; %Hz
t = 0:1/samp:1; % Time vector [0,1] sampled at 1500Hz
x = 10*cos(2*pi*t/f_input); % 500Hz input signal
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top