From: Paul on 21 Jun 2010 10:58 Dear all, I can't seem to get my simple filter working. First I created a simple bandpass filter using fdatool. Response filter=bandfilter Design method=IIR butterworth the specified order =8 the Fs =250Hz Fc1=1Hz Fc2=40Hz If I design this filter i see that this gives a perfect flat magitude response between 2.4 and 28 Hz, which is what I want to achieve. The m-code for this design is: Fs = 250; % Sampling Frequency N = 8; % Order Fc1 = 1; % First Cutoff Frequency Fc2 = 40; % Second Cutoff Frequency h = fdesign.bandpass('N,Fc1,Fc2', N, Fc1, Fc2, Fs); Hd = design(h, 'butter'); Now to filter my input signal, I use: output_filt=filter(Hd,x_input); %with dim(x_input)=1*2500 but this gives: "Empty transfer function." ->How do I solve this? Second since this is a simple butterworth filter I could also use the buttercommand: [B,A]=butter(8,[1 40]/500); Now when I check the magnitude and frequency response with: freqz(B,A) I get a completly different response! ->Why do I not get the sample response as with fdatool? with kind regards, Paul
From: Paul on 21 Jun 2010 11:23 Dear all, I've found a roundabout solution for the first question: if I use the Hd design, I can use the function sos2tf: [B,A]=sos2tf(Hd.sosMatrix,Hd.Scalevalues); to extract the A and B coefficients. then I use filtfilt to filter my input: output=filtfilt(A,B,input); I still don't know why a butterworth design doesn't give the same respons if you design it with fdatool or with the butter function. "Paul " <paul.verkempynck(a)student.kuleuven.be> wrote in message <hvnum2$98r$1(a)fred.mathworks.com>... > Dear all, > > I can't seem to get my simple filter working. > > First I created a simple bandpass filter using fdatool. > Response filter=bandfilter > Design method=IIR butterworth > the specified order =8 > the Fs =250Hz > Fc1=1Hz > Fc2=40Hz > If I design this filter i see that this gives a perfect flat magitude response between 2.4 and 28 Hz, which is what I want to achieve. > > The m-code for this design is: > Fs = 250; % Sampling Frequency > N = 8; % Order > Fc1 = 1; % First Cutoff Frequency > Fc2 = 40; % Second Cutoff Frequency > h = fdesign.bandpass('N,Fc1,Fc2', N, Fc1, Fc2, Fs); > Hd = design(h, 'butter'); > > Now to filter my input signal, I use: > output_filt=filter(Hd,x_input); %with dim(x_input)=1*2500 > but this gives: > "Empty transfer function." > ->How do I solve this? > > Second since this is a simple butterworth filter I could also use the buttercommand: > [B,A]=butter(8,[1 40]/500); > Now when I check the magnitude and frequency response with: > freqz(B,A) > I get a completly different response! > ->Why do I not get the sample response as with fdatool? > > with kind regards, > Paul
|
Pages: 1 Prev: Cleaning up MLintFailureFiles Next: LSQ curve fitting problem |