原创 FIR 调用不同的函数

2011-7-9 19:38 1790 5 9 分类: FPGA/CPLD
close all;
clear all;
clc;

f1=1900;
f2=5100;
f3=7000;
Fs=20000;
N=1000;
n=0:1/FsN-1)/Fs;
y=sin(2*pi*f1.*n)+cos(2*pi*f2.*n)+sin(2*pi*f3.*n);
plot(n,y)
xlabel('Time /sec');
ylabel('Amplitude volts');
title('the signal in Time Domain before filter');

Y=fft(y,N);
F=(0:N-1)*Fs/N;
figure
plot(F,abs(Y))%1
xlabel('Frequency /Hz');
ylabel('Amplitude volts');
title('the signal in Frequency Domain before filter');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

f1=1900;%this signal frequency will be passed in the filter
f2=5100;%this signal frequency will be filtered in the filter
f3=7000;%this signal frequency will be filtered in the filter
Fs=20000;% the sample frequency

%w1/pi=0.19;
w1=2*pi*f1/Fs %normalization in digital frequency domain
wp=0.2*pi;
ws=0.25*pi;
wc=(wp+ws)/2;
width=ws-wp;
order=ceil(6.6*pi/width)+1;
window=hamming(order);
alpha=(order-1)/2;
n=[0:1order-1)];
m=n-alpha+eps;
hd=sin(wc*m)./(pi*m);

b=fir1(order-1,wc/pi,window);

figure
freqz(b,1,512)
figure
freqz(hd,1,512)
sf1 = filter(b,1,y);
sf2 = filter(hd,1,y);
figure
plot(sf1)
figure
plot(sf2)

figure
plot(F,abs(fft(sf1)))
figure
plot(F,abs(fft(sf2)))

PARTNER CONTENT

文章评论4条评论)

登录后参与讨论

FPGADeveloper 2014-7-19 07:57

可以的

用户1645198 2014-7-6 13:21

看了楼主的好几篇文章,请问下楼主,你在设计滤波都是用MATLAB的FDATOOL设计的吗?我最近在解决一个48hz-52HZ的贷通滤波,用MATLAB工具,设计阶数都太高,一直没有弄出来,想咨询下楼主,

FPGADeveloper 2011-7-17 10:11

这个 有注释的哈 可以用FDATOOL来设计

用户468654 2011-7-11 23:21

这个没个注释,看起来有点吃力哟!
相关推荐阅读
FPGADeveloper 2017-04-11 12:03
界面好像比较清爽
界面好像比较清爽,试用下 ...
FPGADeveloper 2015-11-19 17:24
评论:@emesjx's Blog 博客中提到的“高速LVDS接口信号完整性处理实例”
学习看看...
FPGADeveloper 2015-01-02 17:16
2015年FPGA雏鹰培训计划
 ...
FPGADeveloper 2015-01-02 11:05
2015 新年新开始~
2015 新年新开始~...
FPGADeveloper 2014-09-12 23:28
AD DA 测试
AD DA       测试条件           ...
FPGADeveloper 2014-06-13 16:45
5位创始人讲述创业失败的教训
  失败,这是围绕在创业者身上很常见的事情,它常让创业者在很长一段时间内灰心失望。         但是总有一些创业者勇敢的面对失败,从而最后取得成功。我们采访了5位成功的创始...
EE直播间
更多
我要评论
4
5
关闭 站长推荐上一条 /1 下一条