《DSP using MATLAB》示例 Example 9.11
代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Exameple 9.11 \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);
%% ------------------------------------------------------------------------ % Filter Design:
D = 2; Rp = 0.1; As = 30; wp = pi/D; ws = wp+0.1*pi;
[delta1, delta2] = db2delta(Rp, As);
%weights = [delta2/delta1, 1];
[N, F, A, weights] = firpmord([wp, ws]/pi, [1, 0], [delta1, delta2], 2);
h = firpm(N, F, A, weights); n = [0:length(h)-1];
[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); %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- % Input signal
Hf1 = figure('units', 'inches', 'position', [1, 1, 8, 6], ...
'paperunits', 'inches', 'paperposition', [0, 0, 6, 4], ...
'NumberTitle', 'off', 'Name', 'Exameple 9.11');
set(gcf,'Color','white'); TF = 10; subplot(2, 2, 1);
Hs1 = stem(n, h, 'filled'); set(Hs1, 'markersize', 2, 'color', 'g');
axis([-1, length(n), -0.15, 0.6]); grid on;
xlabel('n', 'vertical', 'bottom'); ylabel('Amplitude', 'vertical', 'cap');
title('Inpulse Response ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [n(1), n(end)]);
set(gca, 'ytick', [0, 0.5]); subplot(2, 2, 3);
plot(w/pi, Hr, 'm', 'linewidth', 1.0); axis([0, 1, -0.1, 1.1]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
title('Amplitude Response', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [0, 1]); subplot(2, 2, 2);
plot(w/pi, Hdb, 'm', 'linewidth', 1.0); axis([0, 1, -50, 10]); grid on;
xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Decibels', 'vertical', 'cap');
title('Log-magnitude Response ', 'fontsize', TF, 'vertical', 'baseline');
set(gca, 'xtick', [0, wp/pi, ws/pi, 1]);
set(gca, 'ytick', [-50, round(min_attn), 0]); subplot(2, 2, 4);
lw = length(w)-1; PB = [0:floor(wp/pi*lw)]; HrPB = Hr(PB+1)-1;
SB = [ceil(ws/pi*lw):lw]; HrSB = Hr(SB+1);
[AX, H1, H2] = plotyy(PB/lw, HrPB, SB/lw, HrSB);
delta1 = round(delta1*1000)/1000; delta2 = round(delta2*100)/100;
set(AX(1), 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [-delta1, 0, delta1], 'Ycolor', 'g');
set(AX(2), 'xtick', [0, wp/pi, ws/pi, 1], 'ytick', [-delta2, 0, delta2], 'Ycolor', 'r'); set(H1, 'color', 'g', 'linewidth', 1);
set(H2, 'color', 'r', 'linewidth', 1);
title('Unweighted Ripples', 'fontsize', TF, 'vertical', 'baseline'); xlabel('Frequency in \pi units', 'vertical', 'middle'); ylabel('Amplitude', 'vertical', 'cap');
运行结果:
滤波器在通带[0,π/2]上无畸变通过信号。但是,因为过渡带较宽,所以过渡带中的信号有可能假频混入到感兴趣的频带
中。30dB的衰减可能使得在减采样过程后阻带的部分谱折叠到通带中。因此,我们需要一个更好的方法。
《DSP using MATLAB》示例 Example 9.11的更多相关文章
- 《DSP using MATLAB》Problem 7.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.11
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.11
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 《DSP using MATLAB》Problem 8.11
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- DSP using MATLAB 示例 Example3.11
用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...
- DSP using MATLAB 示例Example2.11
上代码: b = [1]; a = [1, -1, 0.9]; n = [-20:120]; h = impz(b,a,n); set(gcf,'Color','white'); %subplot(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 ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
随机推荐
- 2017年浙江中医药大学程序设计竞赛 Solution
训练地址 A: 树剖板子题 求最小值的时候要注意值是不是有负数,如果有,初值要置为$-INF$ #include <bits/stdc++.h> using namespace std; ...
- HDU1087
/*记忆化dfs+dp,因为每次最多走k步,所以上下左右的方向有所扩展, dp[i][j]存的是从dp[i][j]出发能吃的最大个数*/ #include<stdio.h> #includ ...
- Ubuntu 14.04 下安装 TFTP 艰辛之路【转】
本文转载自:https://blog.csdn.net/donglicaiju76152/article/details/76651210 背景 按说在Linux下安装tftp server 很简单, ...
- 【热更新IK词典】ElasticSearch IK 自动热更新原理与实现
一.热更新原理 elasticsearch开启加载外部词典功功能后,会每60s间隔进行刷新字典.具体原理代码如下所示: public void loadDic(HttpServletRequest r ...
- Java FastJson 介绍
1.前言 1.1.FastJson的介绍: JSON协议使用方便,越来越流行,JSON的处理器有很多,这里我介绍一下FastJson,FastJson是阿里的开源框架,被不少企业使用,是一个极其优秀的 ...
- HDU 4714 Treecycle(树形dp)
http://acm.hdu.edu.cn/showproblem.php?pid=4714 题意:给出一棵树,删除一条边和添加一条边的代价都是1,现在要把这棵树变成环,求需要花的最小代价. 思路: ...
- bootstrap.min.css.map HTTP/1.1" 404 1699
在做一个jsp练习的时候遇到引入bootstrap.css的时候出现了URL:bootstrap.min.css.map 404的错误. 解决办法:删除bootstrap.min.css文件内容最后一 ...
- JavaScript权威指南--Javascript子集和扩展
知识要点 本章讨论javascript的子集和超集,其中子集的定义大部分处于安全考虑.只有使用这门语言的一个安全的子集编写脚本,才能让代码执行的更安全.更稳定.比如如何更安全地执行一段由不可信第三方提 ...
- FastJson/spring boot: json输出方法二
1.引入FastJson依赖包 <!-- FastJson --> <dependency> <groupId>com.alibaba</groupId> ...
- linux挂载windows共享文件夹出错,提示mount error(13): Permission denied
完整的可以工作的命令行: mount -v -t cifs -o username=clouder,password=123456,iocharset=utf8,sec=ntlm //172.28.1 ...