Hi. I was using some matlab functions to show the shapes of some basic butterworth filters when I noticed that my shapes were changing depending on my sampling frequency. Of course, I wouldn't expect this. Can anyone explain why this is happening? Thanks, Blair I have pasted code here which best demonstrates what I mean... % Written by: Blair Fonville % Last Modified: Jan 12, 2009 % Purpose: To demonstrate filter shape dependence on sample rate Colors = ['b','g','r','m','k']; % colors for plotting bw = 20; % Fixed Bandwidth (2-sided) F = linspace(-bw,bw,1000); % 1000 points in result fs = linspace(bw*2.0, bw*200.0, 200); % Create a set of sample rates for i = 1:200 % create filter [b,a]=butter(6, bw / fs(i)); % Create filter [Hb, f] = freqz(b,a,F,fs(i)); % Create gain function hdB = 20*log10(abs(Hb)); % Convert complex pwr to dB % plot filter plot(f, hdB, Colors(mod(i-1,5)+1)); hold on end % misc plot labeling title(sprintf(... 'Filter Shape vs Sample rate. %6.3f MHz, %d Pole Butterworth', ... bw, 6)) ylabel('Gain') xlabel('MHz') axis([-bw, bw, hdB(1)*1.2, 10]) set(gca, 'XGrid', 'on')
matlab filter shape versus sample frequency
Started by ●January 12, 2009
Reply by ●January 12, 20092009-01-12
gps.engine@gmail.com wrote:> Hi. I was using some matlab functions to show the shapes of some basic > butterworth filters when I noticed that my shapes were changing > depending on my sampling frequency. Of course, I wouldn't expect this. > Can anyone explain why this is happening?"Matlab does all thinking for us" (TM) Keyword: Frequency Warping. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●January 12, 20092009-01-12
gps.engine@gmail.com wrote:> Hi. I was using some matlab functions to show the shapes of some basic > butterworth filters when I noticed that my shapes were changing > depending on my sampling frequency. Of course, I wouldn't expect this. > Can anyone explain why this is happening?Express the filter's critical frequencies as a fraction of the sample rate and the shapes, scaled to fs, will all be the same. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●January 12, 20092009-01-12
On Jan 12, 3:00�pm, Jerry Avins <j...@ieee.org> wrote:> gps.eng...@gmail.com wrote: > > Hi. I was using some matlab functions to show the shapes of some basic > > butterworth filters when I noticed that my shapes were changing > > depending on my sampling frequency. Of course, I wouldn't expect this. > > Can anyone explain why this is happening? > > Express the filter's critical frequencies as a fraction of the sample > rate and the shapes, scaled to fs, will all be the same. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > �����������������������������������������������������������������������I did, The code was pasted in the original post. Thanks
Reply by ●January 12, 20092009-01-12
gps.engine@gmail.com wrote:> On Jan 12, 3:00 pm, Jerry Avins <j...@ieee.org> wrote: >> gps.eng...@gmail.com wrote: >>> Hi. I was using some matlab functions to show the shapes of some basic >>> butterworth filters when I noticed that my shapes were changing >>> depending on my sampling frequency. Of course, I wouldn't expect this. >>> Can anyone explain why this is happening? >> Express the filter's critical frequencies as a fraction of the sample >> rate and the shapes, scaled to fs, will all be the same. >> >> Jerry >> -- >> Engineering is the art of making what you want from things you can get. >> ����������������������������������������������������������������������� > > I did, The code was pasted in the original post.So when the sample rate changes, the band edges do too? A filter with a 2 KHz cutoff and an 8 KHz sample rate is also a filter with a 6 KHz cutoff and an 24 KHz sample rate. Vladimir's insight is probably more germane than mine. Changing the sample rate while keeping the cutoff the same will change the way frequency warping affects the transition region. There is very little warp at low frequencies, but it increases rapidly near fs/2. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●January 12, 20092009-01-12
On Jan 12, 3:17�pm, Jerry Avins <j...@ieee.org> wrote:> gps.eng...@gmail.com wrote: > > On Jan 12, 3:00 pm, Jerry Avins <j...@ieee.org> wrote: > >> gps.eng...@gmail.com wrote: > >>> Hi. I was using some matlab functions to show the shapes of some basic > >>> butterworth filters when I noticed that my shapes were changing > >>> depending on my sampling frequency. Of course, I wouldn't expect this. > >>> Can anyone explain why this is happening? > >> Express the filter's critical frequencies as a fraction of the sample > >> rate and the shapes, scaled to fs, will all be the same. > > >> Jerry > >> -- > >> Engineering is the art of making what you want from things you can get. > >> ����������������������������������������������������������������������� > > > I did, The code was pasted in the original post. > > So when the sample rate changes, the band edges do too? A filter with a > 2 KHz cutoff and an 8 KHz sample rate is also a filter with a 6 KHz > cutoff and an 24 KHz sample rate. > > Vladimir's insight is probably more germane than mine. Changing the > sample rate while keeping the cutoff the same will change the way > frequency warping affects the transition region. There is very little > warp at low frequencies, but it increases rapidly near fs/2. >it should be added that this "frequency warping" effect is normally due to the use of the Bilinear Transform for mapping some analog filter to an IIR digital filter. if you look closely at what the MATLAB function "butter()" does, i think you will see that it is designing the Butterworth filter in the "s-plane" and mapping that to the z-plane using the bilinear xform (and then this frequency warping is a well-understood consequence). r b-j