《DSP using MATLAB》Problem 2.14
2024-10-16 01:14:47
代码:
%% ------------------------------------------------------------------------
%% 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;
运行结果:
最新文章
- 《JavaScript高级程序设计》读书笔记 2
- The certificate used to sign ***has either expired or has been revoked. An updated certificate is required to sign and install the application
- 配置SSH框架的心得
- SignalR入门之多平台SignalR服务端
- php-fpm启动
- 动态缓存技术之CSI,SSI,ESI
- 在Flex4中使用RemoteObjectAMF0来连接fluorine网关 转
- markdown2 在win10下无法预览解决方案
- 【破解】破解ACDSEE15的方法
- PHP --字符串编码转换(自动识别原编码)
- Android学习路径(七)建立Action Bar
- 伸缩的菜单,用toggle()重写
- 在线激活win10、win8/8.1和office2019、2016、2013等的kms激活工具
- Android Getting Started
- RxJS 实现摩斯密码(Morse) 【内附脑图】
- java中循环遍历实体类的属性和数据类型以及属性值
- Java多线程面试题整理
- How to get all Errors from ASP.Net MVC modelState?
- git如何merge github forked repository里的代码更新?(转)
- django面试七
热门文章
- 解决 failed to push some refs to &#39;git@github.com:zle1992/head-first-java&#39; hint: Updates were rejected because the tip of your curr
- HDU1059 二进制拆分优化多重背包
- 《JDK 8.0 学习笔记》1~3章
- HTTP-java模拟Get请求小栗子
- hbase(三)coprocessor
- BZOJ 3122 【SDOI2013】 随机数生成器
- Mediator(中介者)
- a href 属性
- 递归--练习10--noi1696逆波兰表达式
- JAVA锁机制(上)