项目里面有用到插值滤波器的场合,用matlab做了前期的滤波器性能仿真,产生的滤波器系数保存下来输入到FPGA IP中使用即可。

下面是仿真的代码

 % clear all
close all Nx = ;
Tx = ;
nx = :Nx-;
x = sin(*pi**nx/Tx);
L = ;
% Ny = L * Nx;
% ny = :Ny-;
% yi = zeros(,Ny);
% yi(:L:Ny) = x;
% figure;
% stem(yi); Fst1 = 0.05;
Fp1 = 0.09;
Fp2 = 0.11;
Fst2 = 0.15;
Ast1 = ;
Ap = 0.01;
Ast2 = ;
% bandpass filter works well, try lowpass to check whether DC signal affects pm
% hband = fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2',Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2);
hband = fdesign.lowpass('Fp,Fst,Ap,Ast',Fp2,Fst2,Ap,Ast2);
Hband = design(hband);
info(Hband); %show filter info Fp = 0.08 %pass band corner freq
Fst = 0.24 %stop band corner freq
Ap = 0.01; %pass band attenuation(dB)
Ast = 80.0; %stop band attenuation(dB)
h1 = fdesign.interpolator(L,'lowpass',Fp,Fst,Ap,Ast);
Href = design(h1);
info(Href); %show filter info
fvtool(Hband,,Href,); %show freq response
title('lowpass filter & interpolator filter');
legend('lowpass filter','interpolator filter'); % import sample_dara
a=dlmread('1.prn');%以字符形式打开文件
v1=a(:,); %16进制转化为10进制数,存储进v1矩阵
figure;
subplot(,,);
plot(v1);
v2 = filter(Hband,v1);
subplot(,,);
plot(v2);
y = filter(Href,v2);
subplot(,,);
plot(y);
% b=dlmread('2.prn');%以字符形式打开文件
% y=b(:,); %16进制转化为10进制数,存储进v1矩阵 fft_analysis_func(v2,//, );
legend('lowpass filter');
fft_analysis_func(y,*L//, );
legend('interpolator filter'); %axis([ - ]) %zoom-in to 25MHz
%generating the coe file
ref_filter = Hband.Numerator;
gen_coe_rad10(Hband.Numerator,'lowpass_filter_rad10.coe');
ref_filter = Href.Numerator;
gen_coe_rad10(Href.Numerator,'inter_filter_rad10.coe');

代码中用到了两个函数

function fft_analysis_func(x, fs, adc_width)

%The following program code plots the FFT spectrum of a desired test tone. Test tone based on coherent sampling criteria, and
%computes SNR, SINAD, THD and SFDR.
%This program is believed to be accurate and reliable. This program may get altered without prior notification.; %fid=fopen('F:\pelican_ADC_test\vjtag_prj\data_analysis\single_tone.txt','r');
%numpt=input('Number of Points in FFT? ');
%fclk=input('Sampling Frequency (MHz)? ');
%numbit=input('ADC Resolution (bits)? '); % numpt=length(x);
numpt = ;
fclk=fs;
numbit=adc_width; v1 = x(:numpt); code=v1'; %Warning: ADC output may be clipping - reduce input amplitude
if (max(code)==2^numbit-1) | (min(code)==0)
disp('WARNING: ADC OUTPUT MAYBE CLIPPING - CHECK INPUT AMPLITUDE!');
end Dout=code;
Voltage=Dout./((2^numbit-1)/2)*(0.5); Doutw=(Dout').*blackmanharris(numpt); %add Minimum -term Blackman-Harris window
Dout_spect=fft(Doutw);
Dout_dB=*log10(abs(Dout_spect)); figure;
maxdB=max(Dout_dB(:numpt/)); %numpt points FFT result in numpt/ points spectrum %计算距离满量程的幅度差
max_voltage=max(Voltage);
delta_amplitude=*log10(max_voltage/0.5); %full scale voltage amplitude is .5v plot([:numpt/-].*fclk/numpt,Dout_dB(:numpt/)-maxdB+delta_amplitude);
% plot([:numpt-].*fclk/numpt,Dout_dB(:numpt)-maxdB+delta_amplitude);
grid on;
title('SINGLE TONE FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (MHz)');
ylabel('AMPLITUDE (dBfs)'); hold off;
function gen_coe_rad10(filt_num, fileName)
%max number of coefficients
num_coeffs = numel(filt_num)
fileId = fopen(fileName,'w');
%header if COE file
fprintf(fileId,'radix = 10;\n');
% first coefficient
fprintf(fileId,'coefdata = \n');
for i = : num_coeffs-
fprintf(fileId,'%8.9f,\n',filt_num(i));
end
% last coefficient
fprintf(fileId,'%8.9f;',filt_num(num_coeffs));
fclose(fileId);
end

仿真出的结果如下:

产生了用于滤波器的系数:

 radix = ;
coefdata =
-0.001219138,
-0.002838337,
-0.005111633,
-0.007197151,
-0.007796326,
-0.005351278,
0.001364815,
0.012476464,
0.026308774,
0.039101106,
0.045443072,
0.039549550,
0.017241585,
-0.021849408,
-0.072532419,
-0.123501332,
-0.158497326,
-0.159275461,
-0.109905781,
-0.001430991,
0.164384860,
0.373413481,
0.600371089,
0.812911647,
0.977825248,
1.067924092,
1.067924092,
0.977825248,
0.812911647,
0.600371089,
0.373413481,
0.164384860,
-0.001430991,
-0.109905781,
-0.159275461,
-0.158497326,
-0.123501332,
-0.072532419,
-0.021849408,
0.017241585,
0.039549550,
0.045443072,
0.039101106,
0.026308774,
0.012476464,
0.001364815,
-0.005351278,
-0.007796326,
-0.007197151,
-0.005111633,
-0.002838337,
-0.001219138;

matlab的滤波器仿真——低通滤波器与插值滤波器的更多相关文章

  1. MATLAB实现最优低通滤波器的函数

    MATLAB实现最优低通滤波器的函数 % Fs     --Data rate % Fpass  --pass band % Fstop  --Cutoff frequencies % Apass  ...

  2. Matlab 瑞利信道仿真

    转眼间三月都已经过去一半,一直找不到有什么可以写的,一直想等自己把LTE仿真平台搭好后,再以连载的形式记录下来.但是,后来一想,我必须先做好充分的铺垫,在这过程中也遇到了很多问题,及时留下点什么,也是 ...

  3. matlab之simulink仿真入门

    Matlab Simulink仿真工具的应用 ****Simulink是一个用来对动态系统进行建模.仿真和分析的软件包.使用Simulink来建模.分析和仿真各种动态系统(包含连续系统.离散系统和混合 ...

  4. Matlab Robotics Toolbox 仿真计算:Kinematics, Dynamics, Trajectory Generation

    1. 理论知识 理论知识请参考: 机器人学导论++(原书第3版)_(美)HLHN+J.CRAIG著++贠超等译 机器人学课程讲义(丁烨) 机器人学课程讲义(赵言正) 2. Matlab Robotic ...

  5. Matlab绘图基础——图形绘制的插值

    interp1   %1-D data interpolation interpft  %使用fft算法插值     %将原数据x转换到频率域,再逆转换回来更密集的数据采样点 spline    %一 ...

  6. Matlab绘图基础——图形绘制的插值  以及 图像大小的重采样

    使用说明:图形绘制时的插值 interp1   %1-D data interpolation interpft  %使用fft算法插值     %将原数据x转换到频率域,再逆转换回来更密集的数据采样 ...

  7. matlab 高阶(三)—— 插值(fft、)

    1. FFT 插值 y = interpft(x,n) y = [0, .5, 1., 1.5, 2., 1.5, 1., .5, 0, -.5, -1, -1.5, -2., -1.5, -1., ...

  8. MATLAB——神经网络sim仿真函数

  9. Matlab 高斯_拉普拉斯滤波器处理医学图像

    前言:本程序是我去年实现论文算法时所做.主要功能为标记切割肝脏区域.时间有点久,很多细节已经模糊加上代码做了很多注释,因此在博客中不再详述. NOTE: 程序分几大段功能模块,仔细阅读,对解决医学图像 ...

随机推荐

  1. win10下 homestead 安装

    1.安装VirtualBox 和 Vagrant 2.git或者composer安装 homestead git clone https://github.com/laravel/homestead. ...

  2. AppStore遭遇大BUG

    用AppLoader上传,提示这个 The u option must have a non-empty value.The password must have a non-empty value. ...

  3. 我是如何社工TDbank获取朋友隐私的

    原创 ziwen@beebeeto 转载请保留本行 个人感觉 国外的安全方面对社工的了解和防范并不是很好 即使他们使用社工的时间比我们要长很多 比如 他们的visa在pos机上使用是不需要密码的 而且 ...

  4. Java中对数据库的查询和增加内容

    先添加jar包 查询数据库中的信息 加载访问驱动,com.mysql.jdbc.Driver--连接到库--写SQL语句 用while循环把表中的信息从第一条到最后一条打印出来,括号中的数字是代表数据 ...

  5. JSP学习流程

  6. ANYBUS AB9005-B配置

    连接 使用232时,要将anybus的2.3脚短路,还有就是Rx和Tx脚分别为7.8,要参照我们需要通讯设备的针脚重新制作232电缆. 正常连接时连接灯(COM\LA1\LA2)为绿色闪烁. TCOM ...

  7. 【HDU1730】Northcott Game(Nim问题)

    Northcott Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. CefSharp 初用遇到的一些问题及解决方法

    之前用WebBrowser,打开网页很卡,但因为并是太要求速度和体验,所以可以显示html就可以了.但是,现在要求显示速度,最主要问题是WebBrowser控件的UserAgent,其实并不完全是IE ...

  9. 简介 – ASP.NET MVC 4 系列

           正所谓好记性不如烂笔头,尤其是技术类书籍在阅读后,时间久了一定会忘记.而重新翻阅整本书也较为低效,遂以博客记录阅读摘要以供日后查阅.本系列文章均摘要自 Wrox 红皮书[ASP.NET ...

  10. form表单修改label样式

    <?php $form = ActiveForm::begin([ 'options'=>['enctype'=>'multipart/form-data','class' => ...