cyfile / Matlab-miscellanies

各种Matlab代码
0 stars 0 forks source link

Filter Design #2

Open 213cy opened 9 years ago

213cy commented 9 years ago

untitled3

untitled4

213cy commented 9 years ago

Fs = 1000; % Sampling Frequency %% t = 0:1/Fs:2;
y = chirp(t,0,1,100);
ax(1)=subplot(421); plot(y) axis tight subplot(422) spectrogram(y,256,192,256,Fs,'yaxis'); ylim([0,250]) %% IIR elliptic filter Rp = 1; Rs = 20; Wp = 80; Ws = 120; [n,Wp_n] = ellipord(2_Wp/Fs,2_Ws/Fs,Rp,Rs); [b,a] = ellip(n,Rp,Rs,Wp_n); % y_IIR=filter(b,a,y); ax(2)=subplot(423); plot(y_IIR) axis tight subplot(424) spectrogram(y_IIR,256,192,256,Fs,'yaxis'); ylim([0,250]) %% FIR hann win filter(Signal Processing Toolbox function) % 40 决定的 hann n2=round((4_Fs/Wp-1)/2); b2=fir1(n2-1,2_Wp/Fs,hann(n2)); y_hann=filter(b2,1,y); ax(3)=subplot(425); plot(y_hann) axis tight subplot(426) spectrogram(y_hann,256,192,256,Fs,'yaxis'); ylim([0,250]) %% FIR kaiser win filter(DSP Toolbox function) Fpass = 80; % Passband Frequency Fstop = 120; % Stopband Frequency Apass = 1; % Passband Ripple (dB) Astop = 20; % Stopband Attenuation (dB) % Construct an FDESIGN object and call its design method. h = fdesign.lowpass(Fpass, Fstop, Apass, Astop, Fs); %set(h); get(h); designmethods(h); Hd = design(h,'kaiserwin'); % y_kaiser=filter(Hd,y); ax(4)=subplot(427); plot(y_kaiser) axis tight subplot(428) spectrogram(y_kaiser,256,192,256,Fs,'yaxis'); ylim([0,250]) %% linkaxes(ax) %% fvtool(b,a,b2,1,Hd.Numerator,1) legend('elliptic','hann','kaiser')