《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 ...
随机推荐
- linux C 程序内存布局
参考: 1. http://www.cnblogs.com/clover-toeic/p/3754433.html 2. http://www.cnblogs.com/jacksu-tencent/p ...
- centos7 lua安装
yum -y install gcc automake autoconf libtool makeyum install readline-develcurl -R -O http://www.lua ...
- html 音频
<!DOCTYPE html><meta charset="utf-8"><video src="movie.webm" cont ...
- ng-深度学习-课程笔记-10: 机器学习策略2(Week2)
1 误差分析( Carrying out error analysis ) 假设你训练了一个猫的二分类模型,在开发集上的错误率是10%,你想分析这10%的错误率来自哪里,怎么做呢? 先把这些错分的图片 ...
- Linux命令: grep命令
基本用法 ...
- Spring整合Quartz定时发送邮件
功能描述:刚开始接触Quartz,试着用Quartz整合spring实现每隔一分钟发送一封邮件连续发送10次 核心jar: 邮件发送:commons-email-1.2.jar mail.jar(必须 ...
- Vue学习笔记之Vue的箭头函数
0x00 箭头函数 基本语法: ES6允许使用“箭头”(=>)定义函数 var f = a = > a //等同于 var f = function(a){ return a; } 如果箭 ...
- 使用 p4-graphs 命令将p4程序依赖关系图形化
位置:/home/wasdns/p4factory/targets/l2_switch/p4src 命令: cd /home/wasdns/p4factory/targets/l2_switch/p4 ...
- linux启停jar包的shell脚本
start.sh 启动脚本 #!/bin/bashcd /home/hygwnohup java -jar hy-web.jar >> /home/hygw/logs/server.lo ...
- POJ 1239 Increasing Sequences(经典的两次dp)
http://poj.org/problem?id=1239 题意:给出一串序列,现在要添加逗号作为分隔符,使得序列是递增序列,然后让最后一个数尽量小,第一个数尽量大. 思路:先从头到尾进行一次dp, ...