《DSP using MATLAB》Problem 2.8

1、代码:
从MATLAB官方网上下载的。
%*************************************************************************%
%A code for the Downsampler%
%Author: Yashwant Marathe%
%Date:20-12-2010%
function [y ny] = dnsample(x,n,M)
%x is a sequence over indices specified by vector n,M is the downsampling factor. param=n/M;
%generates the parameter vector.This vector will decide which input samples will be present in the output. samp=fix(param)==param;
%only those output vectors corresponding to indices where samp==1 will be present in the output. y=x(samp==1);
%generates the output sequence ny=n(samp==1)/M;
%generates the indices of the output sequence end
%**************************************************************************
2、代码
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.8.2 \n\n'); banner();
%% ------------------------------------------------------------------------ n = [-50:1:50];
x = sin( 0.125 * pi * n ); M = 4; [y, m] = dnsample(x, n, M); figure('NumberTitle', 'off', 'Name', 'Problem 2.8.2')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(n, x); title('x sequence');
xlabel('n'); ylabel('x(n)') ;
grid on
subplot(2,1,2); stem(m, y); title('y sequence');
xlabel('n'); ylabel('y(m)');
grid on;
运行结果:

3、代码
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.8.3 \n\n'); banner();
%% ------------------------------------------------------------------------ n = [-50:1:50];
x = sin( 0.5 * pi * n ); M = 4; [y, m] = dnsample(x, n, M); figure('NumberTitle', 'off', 'Name', 'Problem 2.8.3')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(n, x); title('x sequence');
xlabel('n'); ylabel('x(n)') ;
grid on
subplot(2,1,2); stem(m, y); title('y sequence');
xlabel('n'); ylabel('y(m)');
grid on;
运行结果:

《DSP using MATLAB》Problem 2.8的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- (3)在Windows7上搭建Cocos2d-x
工具准备 搭建开发环境需要安装工具包括 Visual Studio python ———(本教程以python2.7.3版本为例),下载地址:http://www.python.org/downloa ...
- cocos代码研究(19)Widget子类ImageView学习笔记
理论基础 显示图片的小控件,继承自 Widget . 代码实践 static ImageView * create()创建一个空的ImageView static ImageView * create ...
- HIVE: 自定义TextInputFormat (旧版MapReduceAPI ok, 新版MapReduceAPI实现有BUG?)
我们的输入文件 hello0, 内容如下: xiaowang 28 shanghai@_@zhangsan 38 beijing@_@someone 100 unknown 逻辑上有3条记录, 它们以 ...
- WdatePicker设置日期范围
设置 结束日期不超过当天日期:设置 开始日期不超过结束日期:设置 开始日期默认显示当月1日的日期,结束日期显示当天日期?<label>开始日期:</label><inpu ...
- TED #05# How we can face the future without fear, together
Rabbi Lord Jonathan Sacks: How we can face the future without fear, together 1. what was it like bei ...
- Python面试题目之打乱打乱有序列表
# 要求打乱一个有序列表 # 待处理列表 L1 = [11,22,33,44,55,66,77,] 方法: # 引入random模块,该模块的shuffle方法见下图 import random L1 ...
- 蜻蜓FM下载文件名还原
从蜻蜓FM手机版可以下载音频文件,目的是可以使用普通的播放器进行音频的播放(只是缓存,还用蜻蜓fm播放的请路过),但问题来了,下载下来的音频文件不是在界面中我们看到的文件名称了.于是,我们要进行一项非 ...
- 在apache中使用.htaccess文件的注意事项
在apache的配置文件中: <VirtualHost *:80> ServerName tp5.com DocumentRoot d:/wamp/www/tp5.com/public & ...
- 初识PHP(三)面向对象特性
PHP5开始支持面向对象的编程方式.PHP的面向对象编程方法和别的语言区别不大,下面对PHP面向编程基本语法进行简单记录. 一.声明对象 声明方法: class Say{ public functio ...
- AngularJs 控制台
在控制台查看$scope对象 html: 通过控制器里面的一个元素来获取这个控制器的$scope var node=document.getElementById("NewsVote&quo ...