Home >

数字信号处理 —— 第三版 丁玉美 高西全 实验 4 实验四 答案...

13. June 2011
冰糕在这里为大家分享一下实验代码。。。网络上代码可谓是多而相同.并且造成大家很容易出错等的情况发生...
所以冰糕修改版...Matlab程序代码...
 
% IIR数字滤波器设计及软件实现
clear all;close all
Fs=10000;T=1/Fs;   %采样频率

%====以下为产生3路波形信号的代码====================

%st=mstg 返回三路调幅信号相加形成的混合信号,长度N=1600
N = 1600   %N为信号st的长度。
Fs=10000;T=1/Fs;Tp=N*T; %采样频率Fs=10kHz,Tp为采样时间
t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;
fc1=Fs/10;      %第1路调幅信号的载波频率fc1=1000Hz,
fm1=fc1/10;     %第1路调幅信号的调制信号频率fm1=100Hz
fc2=Fs/20;     %第2路调幅信号的载波频率fc2=500Hz
fm2=fc2/10;     %第2路调幅信号的调制信号频率fm2=50Hz
fc3=Fs/40;      %第3路调幅信号的载波频率fc3=250Hz,
fm3=fc3/10;     %第3路调幅信号的调制信号频率fm3=25Hz
xt1=cos(2*pi*fm1*t).*cos(2*pi*fc1*t); %产生第1路调幅信号
xt2=cos(2*pi*fm2*t).*cos(2*pi*fc2*t); %产生第2路调幅信号
xt3=cos(2*pi*fm3*t).*cos(2*pi*fc3*t); %产生第3路调幅信号
st=xt1+xt2+xt3;         %三路调幅信号相加
fxt=fft(st,N);          %计算信号st的频谱

%====以下为绘图部分,绘制st的时域波形和幅频特性曲线====================

subplot(2,1,1)
plot(t,st);grid;xlabel('t/s');ylabel('s(t)');
axis([0,Tp/8,min(st),max(st)]);title('(a) s(t)的波形')
subplot(2,1,2)
stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b) s(t)的频谱')
axis([0,Fs/5,0,1.2]);
xlabel('f/Hz');ylabel('幅度')

%低通滤波器设计与实现=========================================

fp=280;fs=450;
wp=2*fp/Fs;ws=2*fs/Fs;rp=0.1;rs=60;   %DF指标(低通滤波器的通、阻带边界频)
[N,wp]=ellipord(wp,ws,rp,rs); %调用ellipord计算椭圆DF阶数N和通带截止频率wp
[B,A]=ellip(N,rp,rs,wp);      %调用ellip计算椭圆带通DF系统函数系数向量B和A
y1t=filter(B,A,st);     %滤波器软件实现
% 低通滤波器设计与实现绘图部分
figure(2);subplot(3,1,1);
[H,W]=freqz(B,A,1000);
m=abs(H);
plot(W/pi,20*log10(m/max(m)));grid on;
xlabel('\omega/\pi');ylabel('幅度(db)');
axis([0,1,-80,5]);title('损耗函数曲线');
yt='y_1(t)';
subplot(3,1,2);
%时域序列连续曲线绘图
%y1t:信号数据序列;yt:绘图信号的纵坐标名称
n=0:length(y1t)-1;t=n*T;
plot(t,y1t);
xlabel('t/s');ylabel(yt);
axis([0,t(end),min(y1t),1.2*max(y1t)]);

%带通滤波器设计与实现====================================================

fpl=440;fpu=560;fsl=275;fsu=900;
wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];rp=0.1;rs=60; 
[N,wp]=ellipord(wp,ws,rp,rs);    %调用ellipord计算椭圆DF阶数N和通带截止频率wp
[B,A]=ellip(N,rp,rs,wp); %调用ellip计算椭圆带通DF系统函数系数向量B和A
y2t=filter(B,A,st);     %滤波器软件实现

%高通滤波器设计与实现================================================

fp=890;fs=600;
wp=2*fp/Fs;ws=2*fs/Fs;rp=0.1;rs=60;   %DF指标(低通滤波器的通、阻带边界频)
[N,wp]=ellipord(wp,ws,rp,rs);    %调用ellipord计算椭圆DF阶数N和通带截止频率wp
[B,A]=ellip(N,rp,rs,wp,'high'); %调用ellip计算椭圆带通DF系统函数系数向量B和A
y3t=filter(B,A,st);     %滤波器软件实现
 
 
                       点击下载实验代码Exp4.rar (1.87 kb)
 
 
上面为大家分享的是椭圆滤波器进行滤波最后得到结果下面为大家提供用用BUttor滤波器设置低通的..程序〉。。
clear all;close all;clc;
Fs=10000;T=1/Fs;   %采样频率
%调用信号产生函数mstg产生由三路抑制载波调幅信号相加构成的复合信号st
%产生信号序列向量st,并显示st的时域波形和频谱
st=mstg 
%低通滤波器设计与实现=========================================
fp=260;fs=400;                     %自定义通带、阻带截止频率
wp=2*pi*fp/Fs;ws=2*pi*fs/Fs;Rp=1;As=30;%滤波器技术指标参数,边界频率
[N,wc]=buttord(wp/pi,ws/pi,Rp,As); %计算数字滤波器的阶数N和截止频率wc
                                   %wp/pi,ws/pi为通带、阻带边界频率的归一化值
[B,A]=butter(N,wc);                %计算系统函数分子和分母多项式系数向量B,A
figure;
freqz(B,A);                        %绘出损耗函数
figure;
%sf:信号数据序列,滤波后
sf=filter(B,A,st);                 %调用filter解差分方程,求系统输出信号yt
n=0:length(sf)-1;t=n*T;
subplot(2,1,1)
plot(t,sf);
xlabel('t/s');ylabel('y(t)');
title('滤波后的波形');
N=800                       %N为信号st的长度。
Fs=10000;T=1/Fs;Tp=N*T;     %采样频率Fs=10kHz,Tp为采样时间
t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;
fc1=Fs/10;		            %第1路调幅信号的载波频率fc1=1000Hz,
fm1=fc1/10;   	            %第1路调幅信号的调制信号频率fm1=100Hz
fc2=Fs/20;	 	            %第2路调幅信号的载波频率fc2=500Hz
fm2=fc2/10;   	            %第2路调幅信号的调制信号频率fm2=50Hz
fc3=Fs/40;		            %第3路调幅信号的载波频率fc3=250Hz,
fm3=fc3/10;   	            %第3路调幅信号的调制信号频率fm3=25Hz
xt1=cos(2*pi*fm1*t).*cos(2*pi*fc1*t); %产生第1路调幅信号
xt2=cos(2*pi*fm2*t).*cos(2*pi*fc2*t); %产生第2路调幅信号
xt3=cos(2*pi*fm3*t).*cos(2*pi*fc3*t); %产生第3路调幅信号
%滤波前的波形
subplot(2,1,2);
plot(t,xt3);grid;
xlabel('t/s');ylabel('xt3'); 
title('做对比的波形');
 
function mstg可在树上试验段找到〉。。。
糕网随笔 www.binggao.net 冰糕编辑

Comments (1) -

7/15/2011 3:58:27 PM #
I was searching Google for ????? | ?????? —— ??? ??? ??? ?? 4 ??? ??... and I noticed your low page rank and the fact that you don't get much traffic. No offense. It seems to be a problem these day with the Panda update. Everyone has been getting hit with all of the big guys there to make the real money. I know this looks like spam but I'm serious about this. You can boost your backlinks and thus your traffic 10x even 100X in a few days. There is a software program called Xrumer. You may have heard about it since it's a fairly popular program with the SEO crowd. Below is a little excerpt from Wikipedia. "XRumer is a Windows blackhat SEO program that is able to successfully register and forum spam with the aim of boosting search engine rankings. The program is able to bypass security techniques commonly used by many forums and blogs to deter automated spam, such as account registration, client detection, many forms of CAPTCHAs, and e-mail activation before posting. The program utilises socks and http proxies in an attempt to make it more difficult for administrators to block posts by source IP and features a proxy checking tool to verify the integrity and anonymity of the proxies used." (wikipedia) It would be worth it checking out this program. I highly recommend it. I was able to go from PR0 to PR5 in 2 months. I'm now on the first page of Google and banking like the big boys. Anyways, just a heads up from one webmaster to another. btw, here is a link to a trial of the program if you wan to try it out for free. http://www.xrumertrial.info If you aren't tech savvy you can also have someone else do Xrumer blasts for you. Just check out http://www.xrumerblaster.info

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading