博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
《DSP using MATLAB》Problem 2.4
阅读量:5321 次
发布时间:2019-06-14

本文共 5851 字,大约阅读时间需要 19 分钟。

生成并用stem函数画出这几个序列。

1、代码:

%% ------------------------------------------------------------------------%%            Output Info about this m-filefprintf('\n***********************************************************\n');fprintf('        
Problem 2.4.1 \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);%% ------------------------------------------------------------------------%%%% x(n)={2,4,-3,1,-5,4,7} -3:3%% * %% x1(n) = 2x(n-3) + 3x(n+4) - x(n)x = [2,4,-3,1,-5,4,7]n = [-3:3][x11,n11] = sigshift(x,n,3)[x12,n12] = sigshift(x,n,-4)[x13,n13] = sigshift(x,n,0);[x1,n1] = sigadd(2 * x11, n11, 3 * x12, n12);[x1,n1] = sigadd(x1, n1, -x13, n13)figureset(gcf,'Color','white');stem(n,x); title('x(n)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');stem(n11,x11); title('x11(n)=x(n-3)');xlabel('n'); ylabel('x11(n)');grid on;figureset(gcf,'Color','white');stem(n12,x12); title('x12 = x(n+4)');xlabel('n'); ylabel('x11(n)');grid on;figureset(gcf,'Color','white');stem(n1,x1); title('x1 = 2x(n-3) + 3x(n+4) -x(n))');xlabel('n'); ylabel('x1(n)');grid on;

  运行结果:

2、代码:

%% ------------------------------------------------------------------------%%            Output Info about this m-filefprintf('\n***********************************************************\n');fprintf('        
Problem 2.4.2 \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);%% ------------------------------------------------------------------------%%%% x(n)={2,4,-3,1,-5,4,7} -3:3%% * %% x2(n) = 4x(4+n) + 5x(n+5) + 2x(n)x = [2,4,-3,1,-5,4,7]n = [-3:3][x11,n11] = sigshift(x,n,-4)[x12,n12] = sigshift(x,n,-5)[x13,n13] = sigshift(x,n,0);[x1,n1] = sigadd(4*x11, n11, 5*x12,n12);[x1,n1] = sigadd(x1,n1,2*x13,n13)figureset(gcf,'Color','white');stem(n,x); title('x(n)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');stem(n11,x11); title('x11(n)=x(4+n)');xlabel('n'); ylabel('x11(n)');grid on;figureset(gcf,'Color','white');stem(n12,x12); title('x12 = x(n+5)');xlabel('n'); ylabel('x11(n)');grid on;figureset(gcf,'Color','white');stem(n1,x1); title('x1 = 4x(4+n) + 5x(n+5) +2x(n))');xlabel('n'); ylabel('x1(n)');grid on;

  运行结果:

3、代码:

%% ------------------------------------------------------------------------%%            Output Info about this m-filefprintf('\n***********************************************************\n');fprintf('        
Problem 2.4.3 \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);%% ------------------------------------------------------------------------%%%% x(n)={2,4,-3,1,-5,4,7} -3:3%% * %% x3(n) = x(n+3)x(n-2) + x(1-n)x(n+1)n = [-3:3];x = [2,4,-3,1,-5,4,7];[x11,n11] = sigshift(x,n,-3); [x12,n12] = sigshift(x,n,2); [x13,n13] = sigfold(x,n); [x13,n13] = sigshift(x13,n13,1);[x14,n14] = sigshift(x,n,-1);[x21,n21] = sigmult(x11, n11, x12,n12);[x22,n22] = sigmult(x13, n13, x14,n14);[x3,n3] = sigadd(x21,n21,x22,n22);figureset(gcf,'Color','white');subplot(3,1,1); stem(n,x); title('x(n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,2); stem(n11,x11);title('x(n+3)');xlabel('n'); ylabel('x');grid on;subplot(3,1,3); stem(n12,x12);title('x(n-2)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');subplot(3,1,1); stem(n,x); title('x(n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,2); stem(n13,x13);title('x(1-n)');xlabel('n'); ylabel('x');grid on;subplot(3,1,3); stem(n14,x14);title('x(n+1)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');subplot(2,1,1); stem(n21,x21);title('x(n+3)x(n-2)');xlabel('n'); ylabel('x');grid on; subplot(2,1,2); stem(n12,x12); title('x12 = x(n+5)');title('x(n+3)');xlabel('n'); ylabel('x');grid on;xlabel('n'); ylabel('x11(n)');grid on;figureset(gcf,'Color','white');stem(n3,x3); title('x1 = 4x(4+n) + 5x(n+5) +2x(n))');xlabel('n'); ylabel('x1(n)');grid on;

  运行结果:

4、代码:

%% ------------------------------------------------------------------------%%            Output Info about this m-filefprintf('\n***********************************************************\n');fprintf('        
Problem 2.4.4 \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);%% ------------------------------------------------------------------------%%%% x(n)={2,4,-3,1,-5,4,7} -3:3%% * %% x4(n) = 2exp(0.5n)x(n) + cos(0.1pi*n)x(n+2)n = [-10:10];x = [zeros(1, 7), 2, 4, -3, 1, -5, 4, 7, zeros(1,7)];x11 = exp(0.5*n);x12 = cos(0.1*pi*n);[x13,n13] = sigshift(x,n,-2);[x21,n21] = sigmult(2*x11, n, x, n);[x22,n22] = sigmult(x12, n, x13, n13);[x4,n4] = sigadd(x21, n21, x22, n22);%x4 = 2*exp(0.5*n)*x(n) + cos(0.1*pi*n)*x11(n11);figureset(gcf,'Color','white');subplot(3,1,1); stem(n, x); title('x(n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,2); stem(n, x11);title('exp(0.5n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,3); stem(n, x12);title('cos(0.1\pin)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');subplot(3,1,1); stem(n,x); title('x(n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,2); stem(n21, x21);title('2exp(0.5n)*x(n)'); xlabel('n'); ylabel('x');grid on;subplot(3,1,3); stem(n22, x22);title('cos(0.1\pin)*x(n+2)');xlabel('n'); ylabel('x');grid on;figureset(gcf,'Color','white');stem(n4,x4); title('x4(n) = 2exp(0.5n)x(n) + cos(0.1pi*n)x(n+2)');xlabel('n'); ylabel('x4(n)');grid on;

  运行结果:

 

转载于:https://www.cnblogs.com/ky027wh-sx/p/7859041.html

你可能感兴趣的文章
masm32V11配置
查看>>
ASP.NET中Request.ApplicationPath、Request.FilePath、Request.Path、.Request.MapPath
查看>>
通过Python、BeautifulSoup爬取Gitee热门开源项目
查看>>
正则表达式的用法
查看>>
线程安全问题
查看>>
集合的内置方法
查看>>
IOS Layer的使用
查看>>
Android SurfaceView实战 带你玩转flabby bird (上)
查看>>
Android中使用Handler造成内存泄露的分析和解决
查看>>
android代码控制seekbar的样式
查看>>
servlet
查看>>
SSM集成activiti6.0错误集锦(一)
查看>>
linux下安装python环境
查看>>
pdnovel 看书 读书 听书
查看>>
oracle for loop 代替cursor (转载)
查看>>
Linked List Cycle II
查看>>
工作踩坑记录:JavaScript跳转被缓存
查看>>
个人作业
查看>>
XMLHttpRequest对象
查看>>
c语言选项实现
查看>>