代码:

%T1 = 0.5

M = 40; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
Hrs = [ones(1, 5), 0.5, zeros(1, 29), 0.5, ones(1, 4)]; % Ideal Amp Res sampled
Hdr = [1, 1, 0, 0]; wdl = [0, 0.25, 0.25, 1]; % Ideal Amp Res for plotting
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1; %% --------------------------
%% Type-2 LPF
%% --------------------------
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H = Hrs.*exp(j*angH); h = real(ifft(H, M)); [db, mag, pha, grd, w] = freqz_m(h, 1);
[Hr, ww, a, L] = Hr_Type2(h); %% Plot a figure('NumberTitle', 'off', 'Name', 'Exameple 7.15a')
set(gcf,'Color','white'); subplot(2,2,1); plot(wl(1:21)/pi, Hrs(1:21), 'o', wdl, Hdr); axis([0, 1, -0.1, 1.1]);
xlabel('frequency in \pi nuits'); ylabel('Hr(k)'); title('Frequency Samples: M=40, T1=0.5');
grid on; subplot(2,2,2); stem(l, h); axis([-1, M, -0.1, 0.3]); grid on;
xlabel('n'); ylabel('h(n)'); title('Impulse Response'); subplot(2,2,3); plot(ww/pi, Hr, wl(1:21)/pi, Hrs(1:21), 'o'); axis([0, 1, -0.2, 1.2]); grid on;
xlabel('frequency in \pi units'); ylabel('Hr(w)'); title('Amplitude Response'); subplot(2,2,4); plot(w/pi, db); axis([0, 1, -60, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response');

  运行结果:

最小阻带衰减变成30dB,这比7.14例子要好些。但仍不符要求(50dB)。最佳的T1值需要手动修改来得到,

当然有效的方法是通过线性编程技巧来获得T1,本书中没有提及。最优解T1=0.39,如下:

%T1 = 0.39

M = 40; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
Hrs = [ones(1, 5), 0.39, zeros(1, 29), 0.39, ones(1, 4)]; % Ideal Amp Res sampled
Hdr = [1, 1, 0, 0]; wdl = [0, 0.25, 0.25, 1]; % Ideal Amp Res for plotting
k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1; angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
H = Hrs.*exp(j*angH); h = real(ifft(H, M)); [db, mag, pha, grd, w] = freqz_m(h, 1);
[Hr, ww, a, L] = Hr_Type2(h); %% Plot b figure('NumberTitle', 'off', 'Name', 'Exameple 7.15b')
set(gcf,'Color','white'); subplot(2,2,1); plot(wl(1:21)/pi, Hrs(1:21), 'o', wdl, Hdr); axis([0, 1, -0.1, 1.1]); grid on;
xlabel('frequency in \pi nuits'); ylabel('Hr(k)'); title('Frequency Samples: M=40, T1=0.39'); subplot(2,2,2); stem(l, h); axis([-1, M, -0.1, 0.3]); grid on;
xlabel('n'); ylabel('h(n)'); title('Impulse Response'); subplot(2,2,3); plot(ww/pi, Hr, wl(1:21)/pi, Hrs(1:21), 'o'); axis([0, 1, -0.2, 1.2]); grid on;
xlabel('frequency in \pi units'); ylabel('Hr(w)'); title('Amplitude Response'); subplot(2,2,4); plot(w/pi, db); axis([0, 1, -60, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response');

  运行结果:

最优阻带衰减现在是43dB,很明显如果想进一步增加阻带衰减As,那么就需要变动过渡带中1个以上的样点。

《DSP using MATLAB》示例Example7.15的更多相关文章

  1. 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 ...

  2. 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 ...

  3. DSP using MATLAB 示例 Example3.19

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

  4. DSP using MATLAB示例Example3.18

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

  5. DSP using MATLAB 示例 Example3.11

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...

  6. DSP using MATLAB 示例Example3.9

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

  7. DSP using MATLAB 示例Example3.8

    代码: x = rand(1,11); n = 0:10; k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points. X = ...

  8. DSP using MATLAB 示例Example3.7

    上代码: x1 = rand(1,11); x2 = rand(1,11); n = 0:10; alpha = 2; beta = 3; k = 0:500; w = (pi/500)*k; % [ ...

  9. DSP using MATLAB示例Example3.6

    代码: n = [-5:5]; x = (-0.9).^n; % x(n) = k = -200:200; w = (pi/100)*k; % [0,pi] axis divided into 101 ...

随机推荐

  1. [转]Linux下RPM软件包的安装及卸载 yum操作

    在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat Package Manager ,是由Redhat 公司提出的,用于管理Linux 下 ...

  2. Linux:redhat6.5使用yum时提示需要注册问题解决方案

    Linux:redhat6.5使用yum时提示需要注册问题解决方案 一.问题 新安装了redhat6.5.安装后,登录系统,使用yum时候.提示: This system is not registe ...

  3. Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    Mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Linux: MyS ...

  4. Sybase:SAP IQ学习笔记

    Sybase:SAP IQ学习笔记 -- 启动IQ管理 >> start_iq -n utility_db -n utility_db >> dbisql -c "u ...

  5. 20145235李涛《网络对抗》Exp5 MSF基础应用

    基础问答 用自己的话解释什么是exploit,payload,encode? exploit:相当于搬运工,把攻击代码传送到靶机中. payload:相当于shellcode. encode:相当于包 ...

  6. React Native之Fetch简单封装、获取网络状态

    1.Fetch的使用 fetch的使用非常简单,只需传入请求的url fetch('https://facebook.github.io/react-native/movies.json'); 当然是 ...

  7. Linux系统下使用pwgen生成密码的使用教程

    pwgen生成的密码易于记忆且相当安全.从技术上来说,容易记忆的密码不会比随机生成的密码更加安全.但是,在大多数情况下,pwgen生成的密码已经足够安全,除了网银密码等需要高安全等级的情况外.使用易于 ...

  8. Spring Cloud 微服务开放平台接口

    github源码地址:https://github.com/spring-cloud/spring-cloud-security 前言: 什么是开放平台接口 场景 : 总公司与子公司 对接接口  还有 ...

  9. vim与shell终端操作技巧

    一.快速注释多行代码 1.添加//注释符 :10,50s#^#//#g       使用#作为分隔符 2.删除//注释符 :10,50s#^//##g       使用#作为分隔符 3.添加#注释符 ...

  10. Spring与CXF整合

    1.首先引入CXF相关jar包以及spring相关jar包,因项目是maven项目,所以直接在pom.xml文件中引入以下依赖即可(以下只是CXF的依赖包,Spring的也要引入,相关的依赖参考我博客 ...