《DSP using MATLAB》Problem 2.14

代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.14 \n\n'); banner();
%% ------------------------------------------------------------------------ n1 = [-10:30];
x1 = cos(pi*n1/4) .* (stepseq(-5, -10, 30)-stepseq(25, -10, 30)); n2 = [-10:30];
x2 = (0.9 .^ (-n2)) .* (stepseq(0, -10, 30) - stepseq(20, -10, 30)); n3 = [-10:10];
x3 = round( 5 * (-1+2*rand(21,1))); [x4, n4] = impseq(2, -10, 30); figure('NumberTitle', 'off', 'Name', 'Problem 2.14')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(4,1,1); stem(n1, x1); title('x1=cos(\pin/4)[u(n+5)-u(n-25)] sequence');
xlabel('n1'); ylabel('x(n)') ;
grid on
subplot(4,1,2); stem(n2, x2); title('x2=(10/9)^n[u(n)-u(n-20)] sequence');
xlabel('n2'); ylabel('x2(n2)');
grid on; subplot(4,1,3); stem(n3, x3); title('x3=round(5w(n)) sequence');
xlabel('n3'); ylabel('x3(n3)');
grid on; subplot(4,1,4); stem(n4, x4); title('x4=\delta(n-2) sequence');
xlabel('n4'); ylabel('x4(n4)');
grid on; %% ------------------------------------------
%% Commutation
%% ------------------------------------------
[y1, ny1] = conv_m(x1, n1, x2, n2);
[y2, ny2] = conv_m(x2, n2, x1, n1); figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Commutation')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny1, y1); title('x1*x2 sequence');
xlabel('ny1'); ylabel('y1(n)') ;
grid on
subplot(2,1,2); stem(ny2, y2); title('x2*x1 sequence');
xlabel('ny2'); ylabel('y2(n)');
grid on; %% -----------------------------------------------
%% Association
%% -----------------------------------------------
[y1, ny1] = conv_m(x1, n1, x2, n2);
[y2, ny2] = conv_m(y1, ny1, x3, n3); [y3, ny3] = conv_m(x2, n2, x3, n3);
[y4, ny4] = conv_m(y3, ny3, x1, n1); figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Association')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny2, y2); title('(x1*x2)*x3 sequence');
xlabel('ny2'); ylabel('y2(n)') ;
grid on
subplot(2,1,2); stem(ny4, y4); title('x1*(x2*x3) sequence');
xlabel('ny4'); ylabel('y4(n)');
grid on; %% ------------------------------------------------
%% Distribution
%% ------------------------------------------------
[y1, ny1] = sigadd(x2, n2, x3, n3);
[y2, ny2] = conv_m(x1, n1, y1, ny1); [y3, ny3] = conv_m(x1, n1, x2, n2);
[y4, ny4] = conv_m(x1, n1, x3, n3);
[y5, ny5] = sigadd(y3, ny3, y4, ny4); figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Distribution')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny2, y2); title('x1*[x2+x3] sequence');
xlabel('ny2'); ylabel('y2(n)') ;
grid on
subplot(2,1,2); stem(ny5, y5); title('x1*x2+x1*x3 sequence');
xlabel('ny5'); ylabel('y5(n)');
grid on; %% -------------------------------------------------------------
%% Identity
%% ------------------------------------------------------------- [y1, ny1] = conv_m(x1, n1, x4, n4);
[y2, ny2] = sigshift(x1, n1, 2); [y3, ny3] = conv_m(x2, n2, x4, n4);
[y4, ny4] = sigshift(x2, n2, 2); [y5, ny5] = conv_m(x3, n3, x4, n4);
[y6, ny6] = sigshift(x3, n3, 2); figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Identity1')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny1, y1); title('x1*\delta(n-n0) n0=2 sequence');
xlabel('ny1'); ylabel('y1(n)') ;
grid on
subplot(2,1,2); stem(ny2, y2); title('x1(n-n0) sequence');
xlabel('ny2'); ylabel('y2(n)');
grid on; figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Identity2')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny3, y3); title('x2*\delta(n-n0) n0=2 sequence');
xlabel('ny3'); ylabel('y3(n)') ;
grid on
subplot(2,1,2); stem(ny4, y4); title('x2(n-n0) sequence');
xlabel('ny4'); ylabel('y4(n)');
grid on; figure('NumberTitle', 'off', 'Name', 'Problem 2.14 Identity3')
set(gcf,'Color',[1,1,1]) % 改变坐标外围背景颜色 subplot(2,1,1); stem(ny5, y5); title('x3*\delta(n-n0) n0=2 sequence');
xlabel('ny5'); ylabel('y5(n)') ;
grid on
subplot(2,1,2); stem(ny6, y6); title('x3(n-n0) sequence');
xlabel('ny6'); ylabel('y6(n)');
grid on;
运行结果:







《DSP using MATLAB》Problem 2.14的更多相关文章
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.14
说明:这两个小题的数学证明过程都不会,欢迎博友赐教. 直接上代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 4.14
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 《DSP using MATLAB》Problem 8.14
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 6.8
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.7
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- (25)HttpClient session
session概述 session机制 session机制是一种服务器端的机制,服务器使用一种类似于散列表的结构(也可能就是使用散列表)来保存信息. 当程序需要为某个客户端的请求创建一个session ...
- cocos进阶教程(5)回调函数和定时器的使用技巧
cc.CallFunc.create(selector, data) selector:函数名(函数指针) data:参数 table类型 函数写法 function(node,args ) node ...
- 454 Authenti cation failed, please open smtp flag first! (Net::SMTPAuthenticationError)
在用ruby的smtp库发送邮件的时候,出现了这个错误454 Authenti cation failed, please open smtp flag first! (Net::SMTPAuthen ...
- 120. Triangle(动态规划 三角形最小路径 难 想)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- 2016-2017 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) Solution
A:Alphabet Solved. 签. #include<bits/stdc++.h> using namespace std; ]; ]; int main(){ scanf(); ...
- java switch参数类型
switch: switch语句是根据选择因子实现多路选择(也就是说从一系列执行路径中挑选一个)的一种干净利落的方法. 1.java5之前: switch只能使用能自动转化为int类型的参数:byte ...
- Ubuntu安装 jdk.rpm 报错问题解决
报错问题出现原因 第一次使用Ubuntu操作系统,很多命令及软件安装方式与以往使用的Linux操作系统(CentOS)有很大区别.现在总结使用Ubuntu在安装JDK中,遇到的问题及解决方法. roo ...
- numpy数组广播
numpy数组的广播功能强大,但是也同时让人疑惑不解,现在让我们来谈谈其中的原理. 广播原则: 如果两个数组的后缘维度(即:从末尾开始算起的维度)的轴长相符或其中一方的长度为1,则认为它们是广播兼容的 ...
- 一个简单的Python字符串处理文件
#!/usr/bin/env python3 import re def lineprocess(line): res = '' index = 47 if line[index] == 'e': i ...
- Cloud Native 环境
当今软件行业正发生着巨变.自上世纪50年代计算机诞生以来,软件从最初的手工作坊式的交付方式,逐渐演变成为了职业化开发.团队化开发,进而定制了软件件行业的相关规范,形成了软件产业. 今天,无论是大型企业 ...