From: Wayne King on 7 Jan 2010 20:47 "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hi61hi$3md$1(a)fred.mathworks.com>... > "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. Hi, Yes, the code above gives an FIR equiripple filter. We know your sampling frequency, but what is your passband, or cutoff frequency? Also, I'm curious you have to limit your filter order to that degree? Do you have some computational reason for this? In the above example, we are passing everything above 100 kHz with 60 dB of attenuation in the stopband and 0.5 dB of ripple in the passband. The sampling frequency is 1 MHz. You should copy and paste the following code into the Matlab workspace to see this for yourself: H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); D = design(H,'equiripple'); % Visualize filter fvtool(D) It is easy to adjust the specifications entered in fdesign.highpass() so that you obtain a filter that meets your needs. Hope that helps, Wayne
From: Chuah Kia Yong on 7 Jan 2010 21:10 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hi62qn$p0k$1(a)fred.mathworks.com>... > "Chuah Kia Yong" <kia-yong_chuah(a)agilent.com> wrote in message <hi61hi$3md$1(a)fred.mathworks.com>... > > "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. > > Hi, > Yes, the code above gives an FIR equiripple filter. We know your sampling frequency, but what is your passband, or cutoff frequency? Also, I'm curious you have to limit your filter order to that degree? Do you have some computational reason for this? In the above example, we are passing everything above 100 kHz with 60 dB of attenuation in the stopband and 0.5 dB of ripple in the passband. The sampling frequency is 1 MHz. You should copy and paste the following code into the Matlab workspace to see this for yourself: > > H = fdesign.highpass('N,Fp,Ast,Ap',30,1e5,60,0.5,1e6); > D = design(H,'equiripple'); > % Visualize filter > fvtool(D) > > It is easy to adjust the specifications entered in fdesign.highpass() so that you obtain a filter that meets your needs. > > Hope that helps, > Wayne Hi, Well according to the pre-emphasis filter (75us), 1Hz is at 0db and cutoff at 2122Hz is at 3dB ; when at 4244Hz is at 6dB ; when at 8488Hz is at 12dB ; and when at 15kHz it is at 17dB till my fs/2 is still at 17dB. I'm trying to make it less no if taps so that easier to do when transferring to FPGA program. Thank You.
First
|
Prev
|
Pages: 1 2 Prev: Question regarding TriScatteredInterp Next: extracting data from a netcdf file |