%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% 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. 面试html部分

    1.DOM结构 —— 两个节点之间可能存在哪些关系以及如何在节点之间任意移动. DOM是文档对象模型的简称 DOM模型中两个节点可能存在的关系有两种:父子关系,兄弟关系. 添加节点:appendChi ...

  2. Apache代理转发http到https

    site.conf ProxyPass /maps https://maps.googleapis.com/maps LoadModule proxy_module modules/mod_proxy ...

  3. Collections集合工具类

    一.Collection与Collections Collection 是所有单列集合的根接口 Collection 是操作集合的工具类 二.Collections中常见的方法:(大都是static方 ...

  4. angularjs i18n

    <!doctype html><html ng-app="myApp"><head>    <meta charset="utf ...

  5. type-of-python作业-判断字符串是否属于回文需要忽略其中的标点、空格与大小写

    type-of-python作业 作业练习:要想检查文本是否属于回文需要忽略其中的标点.空格与大小写.例如,"Rise to vote, sir."是一段回文文本,但是我们现有的程 ...

  6. 1. nginx添加自定义http模块(简单)

    步骤 1. 新建模块目录2. 添加模块配置文件3. 编写模块源码文件4. 在主配置文件中配置访问location5. 编译加入模块文件6. 测试 新建模块目录 mkdir /opt/nginx/ext ...

  7. Ubuntu下Caffe实现物体分类

    参考链接: ubuntu下配置Caffe:https://blog.csdn.net/a_z666666/article/details/72853346 https://www.cnblogs.co ...

  8. 提升算法——Adaboost

    思路:通过改变训练样本权重,学习多个分类器,并将这些分类器进行线性组合,提高分类器性能.大多数提升方法都是改变训练数据的概率分布(数据的权值) 强可学习:存在一个多项式的学习算法能够学习他,并且正确率 ...

  9. GUI开发:实时显示摄像头图像

    import tkinter as tk from PIL import Image, ImageTk import cv2 import numpy as np import time g_exit ...

  10. 服务器搭建lamp环境

    使用的例子:服务器版本内核centos 7.04     Xshell连接到您的服务器上,使系统处于最新状态执行以下命令, yum update -y     利用yum命令安装Apache执行命令, ...