From: Chuah Kia Yong on 4 Jan 2010 01:00 Hi, Can anyone here teach me how to come out the pre-emphasis filter formula which can combine my FIR filter and my number of order shouldnt more than 32. From the other forum that i found, the matlab source code is able to produce the pre-emphasis filter but my sampling frequency is high in Mega Hertz so my filter order need to be in thousand order. I doesnt want my filter order to be that high, so does anyone here could help me to solve the problem? Below is the matlab source code that i found online... Thank you. %------------------------------------------------ fs=44100; % sampling frequency tau=50; % time constant in microsecondy (50us for Europe, 75us for Amerika) N=30; % filter order %----- desired frequency response -----% fa=0:1:(fs/2); m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes [dB] %----- design FIR filter (linear phase) -----% %fir2 for frequency-sampling b=fir2(N,(fa/(fs/2)),m); %b=b/sum(b); % if not in comments, the beginning looks fine but the rest doesn't [H,f]=freqz(b,1,22051,fs); % compute transfer function %----- plot everything -----% figure(1) plot(f,abs(H),f,m,'r') grid on axis([100 22050 0 35]) legend('designed', 'desired') set(gca, 'XScale', 'log') figure(2) freqz(b,1) %------------------------------------------------
From: Wayne King on 6 Jan 2010 12:12 "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hhs05l$grc$1(a)fred.mathworks.com>... > Hi, > > Can anyone here teach me how to come out the pre-emphasis filter formula which can combine my FIR filter and my number of order shouldnt more than 32. > > From the other forum that i found, the matlab source code is able to produce the pre-emphasis filter but my sampling frequency is high in Mega Hertz so my filter order need to be in thousand order. > > I doesnt want my filter order to be that high, so does anyone here could help me to solve the problem? > Below is the matlab source code that i found online... > > Thank you. > > %------------------------------------------------ > fs=44100; % sampling frequency > tau=50; % time constant in microsecondy (50us for Europe, 75us for > Amerika) > N=30; % filter order > > %----- desired frequency response -----% > fa=0:1:(fs/2); > m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes > [dB] > > %----- design FIR filter (linear phase) -----% > %fir2 for frequency-sampling > b=fir2(N,(fa/(fs/2)),m); > %b=b/sum(b); % if not in comments, the beginning looks fine but the rest > doesn't > > [H,f]=freqz(b,1,22051,fs); % compute transfer function > > %----- plot everything -----% > figure(1) > plot(f,abs(H),f,m,'r') > grid on > axis([100 22050 0 35]) > legend('designed', 'desired') > set(gca, 'XScale', 'log') > > figure(2) > freqz(b,1) > %------------------------------------------------ Hi, why don't you use fdesign.highpass with one of the specification strings that allow you to specify the filter order (since you seem to have an order constraint) ? After you specify your filter, choose an FIR design method. Specify the sampling frequency as the trailing scalar in the call to fdesign.highpass() % Here I'll use a sampling frequency of 1 MHz H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); % order 30, passband frequency 100 kHz D = design(H,'equiripple'); fvtool(D) %visualize filter magnitude Hope that helps, Wayne
From: Chuah Kia Yong on 6 Jan 2010 22:27 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hi2g94$as8$1(a)fred.mathworks.com>... > "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hhs05l$grc$1(a)fred.mathworks.com>... > > Hi, > > > > Can anyone here teach me how to come out the pre-emphasis filter formula which can combine my FIR filter and my number of order shouldnt more than 32. > > > > From the other forum that i found, the matlab source code is able to produce the pre-emphasis filter but my sampling frequency is high in Mega Hertz so my filter order need to be in thousand order. > > > > I doesnt want my filter order to be that high, so does anyone here could help me to solve the problem? > > Below is the matlab source code that i found online... > > > > Thank you. > > > > %------------------------------------------------ > > fs=44100; % sampling frequency > > tau=50; % time constant in microsecondy (50us for Europe, 75us for > > Amerika) > > N=30; % filter order > > > > %----- desired frequency response -----% > > fa=0:1:(fs/2); > > m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes > > [dB] > > > > %----- design FIR filter (linear phase) -----% > > %fir2 for frequency-sampling > > b=fir2(N,(fa/(fs/2)),m); > > %b=b/sum(b); % if not in comments, the beginning looks fine but the rest > > doesn't > > > > [H,f]=freqz(b,1,22051,fs); % compute transfer function > > > > %----- plot everything -----% > > figure(1) > > plot(f,abs(H),f,m,'r') > > grid on > > axis([100 22050 0 35]) > > legend('designed', 'desired') > > set(gca, 'XScale', 'log') > > > > figure(2) > > freqz(b,1) > > %------------------------------------------------ > > Hi, why don't you use fdesign.highpass with one of the specification strings that allow you to specify the filter order (since you seem to have an order constraint) ? After you specify your filter, choose an FIR design method. Specify the sampling frequency as the trailing scalar in the call to fdesign.highpass() > > % Here I'll use a sampling frequency of 1 MHz > H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); > % order 30, passband frequency 100 kHz > D = design(H,'equiripple'); > fvtool(D) %visualize filter magnitude > > Hope that helps, > Wayne Hi Wayne, Thankz for your reply. I was thinking is it u mean that ignore the program and only paste this few line of code and run it?
From: Wayne King on 7 Jan 2010 02:17 "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hi3ka8$o1q$1(a)fred.mathworks.com>... > "Wayne King" <wmkingty(a)gmail.com> wrote in message <hi2g94$as8$1(a)fred.mathworks.com>... > > "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hhs05l$grc$1(a)fred.mathworks.com>... > > > Hi, > > > > > > Can anyone here teach me how to come out the pre-emphasis filter formula which can combine my FIR filter and my number of order shouldnt more than 32. > > > > > > From the other forum that i found, the matlab source code is able to produce the pre-emphasis filter but my sampling frequency is high in Mega Hertz so my filter order need to be in thousand order. > > > > > > I doesnt want my filter order to be that high, so does anyone here could help me to solve the problem? > > > Below is the matlab source code that i found online... > > > > > > Thank you. > > > > > > %------------------------------------------------ > > > fs=44100; % sampling frequency > > > tau=50; % time constant in microsecondy (50us for Europe, 75us for > > > Amerika) > > > N=30; % filter order > > > > > > %----- desired frequency response -----% > > > fa=0:1:(fs/2); > > > m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes > > > [dB] > > > > > > %----- design FIR filter (linear phase) -----% > > > %fir2 for frequency-sampling > > > b=fir2(N,(fa/(fs/2)),m); > > > %b=b/sum(b); % if not in comments, the beginning looks fine but the rest > > > doesn't > > > > > > [H,f]=freqz(b,1,22051,fs); % compute transfer function > > > > > > %----- plot everything -----% > > > figure(1) > > > plot(f,abs(H),f,m,'r') > > > grid on > > > axis([100 22050 0 35]) > > > legend('designed', 'desired') > > > set(gca, 'XScale', 'log') > > > > > > figure(2) > > > freqz(b,1) > > > %------------------------------------------------ > > > > Hi, why don't you use fdesign.highpass with one of the specification strings that allow you to specify the filter order (since you seem to have an order constraint) ? After you specify your filter, choose an FIR design method. Specify the sampling frequency as the trailing scalar in the call to fdesign.highpass() > > > > % Here I'll use a sampling frequency of 1 MHz > > H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); > > % order 30, passband frequency 100 kHz > > D = design(H,'equiripple'); > > fvtool(D) %visualize filter magnitude > > > > Hope that helps, > > Wayne > > Hi Wayne, > > Thankz for your reply. > I was thinking is it u mean that ignore the program and only paste this few line of code and run it? Hi, yes. I'm suggesting that if you want a pre-emphasis filter, just use fdesign.highpass() and then the design() method to design your filter. If you look at the help for fdesign.highpass, you will see there are a number of ways to specify your filter. Is there a reason you must limit your filter order to be no more than 32? At any rate, there are a number of specification strings in fdesign.highpass(), that allow you to specify the order (such as the one I used in this thread). Once you have designed your filter, you can view its magnitude and phase response (as well as group delay, pole-zero, etc) with fvtool(), and you can apply the filter to your data with filter(). H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); D = design(H,'equiripple'); % now use filter(), I'll just use some junk data y = filter(D,randn(1024,1)); Why don't you give us the specifications you want to use? I'm assuming the code you pasted using frequency sampling is not your desired design because it uses a sampling frequency of 44.1 kHz for starters. Wayne
From: Chuah Kia Yong on 7 Jan 2010 20:25 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hi41ph$3vq$1(a)fred.mathworks.com>... > "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hi3ka8$o1q$1(a)fred.mathworks.com>... > > "Wayne King" <wmkingty(a)gmail.com> wrote in message <hi2g94$as8$1(a)fred.mathworks.com>... > > > "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hhs05l$grc$1(a)fred.mathworks.com>... > > > > Hi, > > > > > > > > Can anyone here teach me how to come out the pre-emphasis filter formula which can combine my FIR filter and my number of order shouldnt more than 32. > > > > > > > > From the other forum that i found, the matlab source code is able to produce the pre-emphasis filter but my sampling frequency is high in Mega Hertz so my filter order need to be in thousand order. > > > > > > > > I doesnt want my filter order to be that high, so does anyone here could help me to solve the problem? > > > > Below is the matlab source code that i found online... > > > > > > > > Thank you. > > > > > > > > %------------------------------------------------ > > > > fs=44100; % sampling frequency > > > > tau=50; % time constant in microsecondy (50us for Europe, 75us for > > > > Amerika) > > > > N=30; % filter order > > > > > > > > %----- desired frequency response -----% > > > > fa=0:1:(fs/2); > > > > m=10*log10(1+((2*tau*fa/1000).^2)*10^(-5)); % corresponding magnitudes > > > > [dB] > > > > > > > > %----- design FIR filter (linear phase) -----% > > > > %fir2 for frequency-sampling > > > > b=fir2(N,(fa/(fs/2)),m); > > > > %b=b/sum(b); % if not in comments, the beginning looks fine but the rest > > > > doesn't > > > > > > > > [H,f]=freqz(b,1,22051,fs); % compute transfer function > > > > > > > > %----- plot everything -----% > > > > figure(1) > > > > plot(f,abs(H),f,m,'r') > > > > grid on > > > > axis([100 22050 0 35]) > > > > legend('designed', 'desired') > > > > set(gca, 'XScale', 'log') > > > > > > > > figure(2) > > > > freqz(b,1) > > > > %------------------------------------------------ > > > > > > Hi, why don't you use fdesign.highpass with one of the specification strings that allow you to specify the filter order (since you seem to have an order constraint) ? After you specify your filter, choose an FIR design method. Specify the sampling frequency as the trailing scalar in the call to fdesign.highpass() > > > > > > % Here I'll use a sampling frequency of 1 MHz > > > H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); > > > % order 30, passband frequency 100 kHz > > > D = design(H,'equiripple'); > > > fvtool(D) %visualize filter magnitude > > > > > > Hope that helps, > > > Wayne > > > > Hi Wayne, > > > > Thankz for your reply. > > I was thinking is it u mean that ignore the program and only paste this few line of code and run it? > > Hi, yes. I'm suggesting that if you want a pre-emphasis filter, just use fdesign.highpass() and then the design() method to design your filter. If you look at the help for fdesign.highpass, you will see there are a number of ways to specify your filter. Is there a reason you must limit your filter order to be no more than 32? At any rate, there are a number of specification strings in fdesign.highpass(), that allow you to specify the order (such as the one I used in this thread). Once you have designed your filter, you can view its magnitude and phase response (as well as group delay, pole-zero, etc) with fvtool(), and you can apply the filter to your data with filter(). > > H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); > D = design(H,'equiripple'); > % now use filter(), I'll just use some junk data > y = filter(D,randn(1024,1)); > > Why don't you give us the specifications you want to use? I'm assuming the code you pasted using frequency sampling is not your desired design because it uses a sampling frequency of 44.1 kHz for starters. > > Wayne Hi, So is this involve the FIR filtering? My fs is about 3MHz and no of taps below 30. i was trying to understand how your program work! Thank You.
|
Next
|
Last
Pages: 1 2 Prev: Question regarding TriScatteredInterp Next: extracting data from a netcdf file |