?? samp5_15.m
字號(hào):
%Samp5_15
wp=[1000 2000]*2*pi;ws=[500 2500]*2*pi;Rp=1;Rs=100; %濾波器設(shè)計(jì)參數(shù),對(duì)于給定Hz應(yīng)乘以2
[N,Wn]=buttord(wp,ws,Rp,Rs,'s'); %求得濾波器的最小階數(shù)和截止頻率
[b,a]=butter(N,Wn,'s'); %設(shè)計(jì)模擬Butterworth濾波器
w=linspace(1,3000,1000)*2*pi; %設(shè)置繪制頻率響應(yīng)的頻率點(diǎn)
H=freqs(b,a,w); %計(jì)算給定頻率點(diǎn)的復(fù)數(shù)頻率響應(yīng)
magH=abs(H);phaH=unwrap(angle(H)); %計(jì)算幅頻響應(yīng)和相頻響應(yīng)
plot(w/(2*pi),20*log10(magH)); %以頻率為橫坐標(biāo)繪制幅頻響應(yīng)
xlabel('頻率/Hz');ylabel('振幅/dB');
title('Butterworth模擬帶通濾波器');
hold on;plot([1000 1000],ylim,'r');plot([2000 2000],ylim,'r');%繪阻帶邊界grid on
figure(2)
dt=1/10000; %模擬信號(hào)采樣間隔
f1=100;f2=1500;f3=2900;%輸入信號(hào)的三個(gè)頻率成分
t=0:dt:0.04; %給定模擬時(shí)間段
x=sin(2*pi*f1*t)+0.5*cos(2*pi*f2*t)+0.5*sin(2*pi*f3*t); %輸入信號(hào)
H=[tf(b,a)]; %濾波器在MATLAB系統(tǒng)中的表示
[y,t1]=lsim(H,x,t); %模擬輸出
subplot(2,1,1),plot(t,x),title('輸入信號(hào)') %繪出輸入信號(hào)
subplot(2,1,2),plot(t1,y) %繪制輸出信號(hào)
title('輸出信號(hào)'),xlabel('時(shí)間/s')
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -