代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.8 \n\n'); time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, 'long');
fprintf(' Now is %20s, and it is %7s \n\n', time_stamp, wkd2);
%% ------------------------------------------------------------------------ I = 5; Rp = 0.1; As = 30; wp = pi/I; ws = wp+pi*0.12;
[delta1, delta2] = db2delta(Rp, As); weights = [delta2/delta1, 1];
F = [0, wp, ws, pi]/pi; A = [I, I, 0, 0];
h = firpm(30, F, A, weights); n = [0:length(h)-1];
[Hr, w, a, L] = Hr_Type1(h); Hr_min = min(Hr); w_min = find(Hr == Hr_min);
H = abs(freqz(h, 1, w)); Hdb = 20*log10(H/max(H)); min_attn = Hdb(w_min); %% -----------------------------------------------------------------
%% Plot
%% -----------------------------------------------------------------
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.8');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n, h, 'filled'); set(Hs1, 'markersize', 2);
axis([-1, length(n), -0.5, 1.5]); grid on;
xlabel('n', 'vertical', 'bottom'); ylabel('Amplitude');
title('Impulse Response', 'fontsize', TF); subplot(2, 2, 3);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -1, 6]); grid on;
xlabel('frequency in \pi units', 'fontsize', 10); ylabel('Amplitude');
title(' Amplitude Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, I]); subplot(2, 2, 2);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -50, 10]); grid on;
xlabel('frequency in \pi units '); ylabel('Decibels');
title('Log-mag Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [-50, round(min_attn), 0]); subplot(2, 2, 4);
lw = length(w)-1; PB = [0:floor(wp/pi*lw)]; HrPB = Hr(PB+1)-I;
SB = [ceil(ws/pi*lw):lw]; HrSB = Hr(SB+1);
[AX, H1, H2] = plotyy(PB/lw, HrPB, SB/lw, HrSB); delta1 = round(delta1*I*100)/100; delta2 = round(delta2*I*100)/100;
set(AX(1), 'xtick', [0, wp/pi, ws/pi, 1]);
set(AX(1), 'ytick', [-delta1, 0, delta1], 'Ycolor', 'g');
set(AX(2), 'xtick', [0, wp/pi, ws/pi, 1]);
set(AX(2), 'ytick', [-delta2, 0, delta2], 'Ycolor', 'r');
set(H1, 'color', 'g', 'linewidth', 1);
set(H2, 'color', 'r', 'linewidth', 1);
title('scaled ripples', 'fontsize', TF);
xlabel('Frequency in \pi units');

  运行结果:

尽管该滤波器通过了原始信号,如果信号是全频带π弧度的,那么邻近的谱能量可能发生泄漏。因此需要更好的设计指标,本节的后面有讨论。

《DSP using MATLAB》示例 Example 9.8的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  6. DSP using MATLAB 示例Example3.17

  7. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  10. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. PR曲线 ROC曲线的 计算及绘制

    在linear model中,我们对各个特征线性组合,得到linear score,然后确定一个threshold,linear score < threshold 判为负类,linear sc ...

  2. PYPI 国内源

    搬砖自http://www.cnblogs.com/sunnydou/p/5801760.html 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学  ...

  3. Python: 二进制、八进制、十六进制转换或者输出

    为了将整数转换为二进制.八进制或十六进制的文本串,可以分别使用bin() ,oct() 或hex() 函数: >>> x = 1234 >>> bin(x) '0b ...

  4. 【小坑】java下载excel文件

    excel文件的导入导出是很常见的功能,这次做了个下载的功能,踩了一些坑,记下来避免以后重复踩…… 1.inputstream序列化问题 Could not write JSON document: ...

  5. linux history记录格式修改

    #保存一万条命令记录 sed -i 's/^HISTSIZE=1000/HISTSIZE=10000/g' /etc/profile #在/etc/profile的文件尾部添加如下行数配置信息 ### ...

  6. 20145122 《Java程序设计》第二周学习总结

    20145122 <Java程序设计>第2周学习总结 教材学习内容总结 在大一的时候我们学习了C语言,所以对第三章的知识不是很陌生,但有些新知识需要记忆. java常用的数据类型: byt ...

  7. Using SQLXML Bulk Load in the .NET Environment

    http://msdn.microsoft.com/en-us/library/ms171878.aspx 1.首先创建一张表 CREATE TABLE Ord ( OrderID ,) PRIMAR ...

  8. python 字典输出键值对

    d = {, , } for dict_key, dict_value in d.items(): print(dict_key,'->',dict_value)

  9. Java回顾之集合

    在这篇文章里,我们关注Java中的集合(Collection).集合是编程语言中基础的一部分,Java自JDK早期,就引入了Java Collection Framework.设计JCF的那个人,后来 ...

  10. 【Python】xlrd,NotImplementedError-formatting_info=True not yet implemented

    前言 Python需要读取Excel(.xls..xlsx)时通常使用xlrd模块:如果要对其内容进行编辑的话稍稍有些麻烦,通常的做法是使用xlutils的copy模块对原文件进行复制,然后保存成新的 ...