《DSP using MATLAB》示例 Example 9.10

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.10 \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);
%% ------------------------------------------------------------------------ % Given parameters:
n = [0:50]; wxp = 0.5*pi; x = cos(wxp*n);
n1 = n(1:9); x1 = x(9:17); % for plotting purposes I = 5; Rp = 0.01; As = 50; wp = wxp/I; ws = (2*pi-wxp)/I;
[delta1, delta2] = db2delta(Rp, As); weights = [delta2/delta1, 1];
[N, Fo, Ao, weights] = firpmord([wp, ws]/pi, [1, 0], [delta1, delta2], 2); N = N + 2;
N %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- % Input signal
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.10');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n1, x1, 'filled'); set(Hs1, 'markersize', 2, 'color', 'g');
axis([-1, 9, -1.2, 1.2]); grid on;
xlabel('n', 'vertical', 'middle'); ylabel('Amplitude');
title('Input Signal x(n)', 'fontsize', TF);
set(gca, 'xtick', [0:4:16]);
set(gca, 'ytick', [-1, 0, 1]); % Interpolation with Filter Design: Length M=31
%M = 31; F = [0, wp, ws, pi]/pi; A = [I, I, 0, 0];
h = firpm(N, Fo, I*Ao, weights); y = upfirdn(x, h, I);
delay = (N)/2; % Delay imparted by the filter
m = delay+1:1:50*I+delay+1; y = y(m); m = 0:40; y = y(81:121); % for plotting subplot(2, 2, 3);
Hs2 = stem(m, y, 'filled'); axis([-5, 45, -1.2, 1.2]); grid on;
set(Hs2, 'markersize', 2, 'color', 'm');
xlabel('m', 'vertical', 'middle'); ylabel('Amplitude');
title(' Output Singal y(n): I = 5', 'fontsize', TF);
set(gca, 'xtick', [0:4:16]*I);
set(gca, 'ytick', [-1, 0, 1]); % Filter Desing Plots
[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); subplot(2, 2, 2);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -1, 6]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude');
title('Amplitude Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, I]); subplot(2, 2, 4);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -70, 10]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Decibels');
title('Log-magnitude Response ', 'fontsize', TF);
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [-70, round(min_attn), 0]);
运行结果:

设计的滤波器最小阻带衰减为53dB。
《DSP using MATLAB》示例 Example 9.10的更多相关文章
- 《DSP using MATLAB》Problem 7.10
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.10
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.10
代码: 第1小题: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Out ...
- 《DSP using MATLAB》Problem 4.10
今天擦完了玻璃,尽管有地方不那么明亮干净,冷风中瑟瑟发抖,年也快临近了. 代码是从网上找的, function [p, np, r, nr] = deconv_m(b, nb, a, na) % Mo ...
- 《DSP using MATLAB》Problem 3.10
用到了三角窗脉冲序列,各小题的DTFT就不写公式了,直接画图(这里只贴长度M=10的情况). 1. 代码: %% ------------------------------------------- ...
- 《DSP using MATLAB》Problem 2.10
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 8.10
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- DSP using MATLAB 示例 Example3.10
用到的性质 上代码: n = -5:10; x = rand(1,length(n)) + j * rand(1,length(n)); k = -100:100; w = (pi/100)*k; % ...
- DSP using MATlAB 示例Example2.10
上代码 % noise sequence 1 x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3]; % given signal x(n) [y,ny] = sigshi ...
- 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 ...
随机推荐
- VS2010/MFC编程入门之二十四(常用控件:列表框控件ListBox)
前面两节讲了比较常用的按钮控件,并通过按钮控件实例说明了具体用法.本文要讲的是列表框控件(ListBox)及其使用实例. 列表框控件简介 列表框给出了一个选项清单,允许用户从中进行单项或多项选择,被选 ...
- android,结合Timer和TimerTask实现定时任务
当我们需要每隔一段时间执行一个任务的时候,就需要使用TimerTask了,下面是入门的例子, 值得注意的是Timer.TimerTask,cancel之后就需要重新声明一个对象,否则会报错的哦~ pa ...
- OpenCV中Denoising相关函数的简单介绍
参考:http://wenhuix.github.io/research/denoise.html一.基本情况 (一)基本方法 Fast Non-Local Me ...
- 基于OpenCV进行图像拼接原理解析和编码实现(提纲 代码和具体内容在课件中)
一.背景 1.1概念定义 我们这里想要实现的图像拼接,既不是如题图1和2这样的"图片艺术拼接",也不是如图3这样的"显示拼接",而是实现类似"BaiD ...
- 20145221 《Java程序设计》第七周学习总结
20145221 <Java程序设计>第七周学习总结 教材学习内容总结 第十二章部分 - Lambda 认识Lambda语法 Lambda去可以重复,符合DRY原则,而且Lambda表达式 ...
- Python3基础 print(,end=) 输出内容的末尾加入空格
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 防止putty的鼠标右键错误粘贴
一.环境 发行版:Ubuntu 18.04.1 LTS 代号:bionic 内核版本:4.15.0-30-generic 二.背景 每次从putty复制时,会单击鼠标右击,以便复制出终端的内容,但是一 ...
- install ros-indigo-camera-info-manager
CMake Warning at /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake: (find_package): Could not fi ...
- HDU-4035-概率dp-期望-公式化简
Maze Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submis ...
- HDU1754 I hate it_线段树(入门级别)
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...