%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 7.23 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
T1 = 0.5
wc = 0.3*pi;
M = 40; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
Hrs = [ones(1, 6), T1, zeros(1, 27), T1, ones(1, 5)]; % Ideal Amp Res sampled
Hdr = [1, 1, 0, 0]; wdl = [0, 0.3, 0.3, 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); delta_w = 2*pi/1000;
[Hr, ww, a, L] = Hr_Type2(h); Rp = -(min(db(1 :1: floor(wc/delta_w)-20))); % Actual Passband Ripple
fprintf('\nActual Passband Ripple is %.4f dB.\n', Rp);
As = -round(max(db(floor(0.35*pi/delta_w)+1 : 1 : 501))); % Min Stopband attenuation
fprintf('\nMin Stopband attenuation is %.4f dB.\n', As); [delta1, delta2] = db2delta(Rp, As) %% Plot a figure('NumberTitle', 'off', 'Name', 'Problem 7.23a')
set(gcf,'Color','white'); subplot(2,2,1); plot(wl(1:21)/pi, Hrs(1:21), 'o', wdl, Hdr, 'r'); axis([0, 1, -0.1, 1.1]);
set(gca,'YTickMode','manual','YTick',[0,0.5,1]);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,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, 'r', 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');
set(gca,'YTickMode','manual','YTick',[0,0.5,1]);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,1]); subplot(2,2,4); plot(w/pi, db); axis([0, 1, -100, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response');
set(gca,'YTickMode','manual','YTick',[-90,-30,0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['90';'30';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,1]); figure('NumberTitle', 'off', 'Name', 'Problem 7.23 h(n)a')
set(gcf,'Color','white'); subplot(2,2,1); plot(w/pi, db); grid on; axis([0 2 -100 10]);
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude Response in dB');
set(gca,'YTickMode','manual','YTick',[-90,-30,0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['90';'30';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,1,1.7,2]);
subplot(2,2,3); plot(w/pi, mag); grid on; axis([0 2 0 1.2]);
xlabel('frequency in \pi units'); ylabel('Absolute'); title('Magnitude Response in absolute');
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,1,1.7,2]);
subplot(2,2,2); plot(w/pi, pha); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Phase Response in Radians');
subplot(2,2,4); plot(w/pi, grd*pi/180); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Rad'); title('Group Delay'); figure('NumberTitle', 'off', 'Name', 'Problem 7.23a Amp Res of h(n) T1=0.5')
set(gcf,'Color','white'); plot(ww/pi, Hr); grid on; %axis([0 1 -100 10]);
xlabel('frequency in \pi units'); ylabel('Hr'); title('Amplitude Response');
set(gca,'YTickMode','manual','YTick',[-delta2,0,delta2,1-delta1,1,1+ delta1])
%set(gca,'YTickLabelMode','manual','YTickLabel',['90';'45';' 0']);
set(gca,'XTickMode','manual','XTick',[0,0.3,0.5,1,1.7,2]);

  运行结果:

《DSP using MATLAB》Problem 7.23的更多相关文章

  1. 《DSP using MATLAB》Problem 6.23

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 4.23

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 5.22

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...

  4. 《DSP using MATLAB》Problem 5.2

    代码: %% ---------------------------------------------------------------------------------- %% Output ...

  5. 《DSP using MATLAB》Problem 4.15

    只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...

  6. 《DSP using MATLAB》Problem 8.34

    今天下了小雨,空气中泛起潮湿的味道,阴冷的感觉袭来,心情受到小小影响. 代码: hp2lpfre子函数 function [wpLP, wsLP, alpha] = hp2lpfre(wphp, ws ...

  7. 《DSP using MATLAB》Problem 8.30

    10月1日,新中国70周岁生日,上午观看了盛大的庆祝仪式,整齐的方阵,先进的武器,尊敬的先辈英雄,欢乐的人们,愿我们的 国家越来越好,人民生活越来越好. 接着做题. 代码: %% ---------- ...

  8. 《DSP using MATLAB》Problem 7.34

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.30

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

随机推荐

  1. asp.net IHttpHandler浅析

    在asp.net程序中,我们可以通过配置url的path路径的方式,将某个path路径下的请求交给指定的IHttpHandler去处理,这便是对request请求进行编程. 一.新建一个framewo ...

  2. 在状态栏增加图标(Android 6.0)

    在Android 启动之后,在SystemServer.java的run方法中,调用了StatusBarManagerService的构造方法,在StatusBarManagerService的构造方 ...

  3. Visual Studio 2017 离线安装包

    vs_community.exe --layout D:vs2017offline-en --add Microsoft.VisualStudio.Workload.ManagedDesktop -- ...

  4. Javase系列之面向对象(一)

    作为一个Java程序员,我们每天做的事情就是OOP(面向对象),可以说万物皆对象,Java是一门面向对象的程序语言,鉴于基本的面向对象知识也是一个较为庞杂的模块,所以博主我准备用多篇文章去介绍Java ...

  5. 查询数据库游标使用情况以及sql

    ----查询游标使用情况以及游标最大数---- SELECT MAX(A.VALUE) AS HIGHEST_OPEN_CUR, P.VALUE AS MAX_OPEN_CUR FROM V$SESS ...

  6. Type curtilage home

    This year's National Day coincides with the Mid-Autumn festival, the double false merger about eight ...

  7. maven源码打包

    1.打包时附加外部Jar包 <!--编译+外部 Jar打包-->          <plugin>            <artifactId>maven-co ...

  8. WORD中引用活动文档元素

    要引用活动的段落.表格.域或其他文档元素,可使用 Selection 属性返回一个 Selection 对象.通过 Selection 对象,可访问选定内容中的所有段落或第一段.下列示例将边框应用于选 ...

  9. UML作业第三次:分析《书店图书销售管理系统》,绘制类图

    一. 类图语法学习小结(类间关系的表示方法) 1.抽象类和接口 我们用关键字abstract或abstract class来定义抽象类(抽象类用斜体显示).也可以使用interface,annotat ...

  10. Python 3 Anaconda 下爬虫学习与爬虫实践 (2)

    下面研究如何让<html>内容更加“友好”的显示 之前略微接触的prettify能为显示增加换行符,提高可阅读性,用法如下: import requests from bs4 import ...