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

1、代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> 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) figure
set(gcf,'Color','white');
stem(n,x); title('x(n)');
xlabel('n'); ylabel('x');grid on; figure
set(gcf,'Color','white');
stem(n11,x11); title('x11(n)=x(n-3)');
xlabel('n'); ylabel('x11(n)');grid on; figure
set(gcf,'Color','white');
stem(n12,x12); title('x12 = x(n+4)');
xlabel('n'); ylabel('x11(n)');grid on; figure
set(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-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> 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) figure
set(gcf,'Color','white');
stem(n,x); title('x(n)');
xlabel('n'); ylabel('x');grid on; figure
set(gcf,'Color','white');
stem(n11,x11); title('x11(n)=x(4+n)');
xlabel('n'); ylabel('x11(n)');grid on; figure
set(gcf,'Color','white');
stem(n12,x12); title('x12 = x(n+5)');
xlabel('n'); ylabel('x11(n)');grid on; figure
set(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-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> 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); figure
set(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; figure
set(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; figure
set(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; figure
set(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-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> 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);
figure
set(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; figure
set(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; figure
set(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;

  运行结果:

《DSP using MATLAB》Problem 2.4的更多相关文章

  1. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.13

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. cocos代码研究(21)Widget子类TextField学习笔记

    基础理论 一个接受用户输入的widget. 输入文本的渲染基于TextFieldTTF. 如果你想用系统控制行为,请使用EditBox来替代.继承自 Widget. 代码实践 //与占位符有关void ...

  2. 2018 Multi-University Training Contest 6 Solution

    A - oval-and-rectangle 题意:给出一个椭圆的a 和 b,在$[0, b]中随机选择c$ 使得四个顶点在椭圆上构成一个矩形,求矩形周长期望 思路:求出每种矩形的周长,除以b(积分) ...

  3. Core Java 3

    p270~p272 1.创建异常类. 步骤:1)定义一个派生于(继承)Exception或者其子类的类. 2)添加两个构造方法:一个是默认构造器,另一个是带有详细描述信息的构造器. import ja ...

  4. SpringBoot Boot内嵌Tomcat

    Spring Boot: SpringBoot-start-web 里面依赖的环境中 如果是外部的Tomcat 容器,可以通过修改config进行配置 内嵌的呢? 如何定制和修改Servlet容器的相 ...

  5. in和exists

    exists和in的使用方式: #对B查询涉及id,使用索引,故B表效率高,可用大表 -->外小内大 select * from A where exists (select * from B ...

  6. 论文笔记——N2N Learning: Network to Network Compression via Policy Gradient Reinforcement Learning

    论文地址:https://arxiv.org/abs/1709.06030 1. 论文思想 利用强化学习,对网络进行裁剪,从Layer Removal和Layer Shrinkage两个维度进行裁剪. ...

  7. BZOJ 3064 CPU监控

    题目链接:CPU监控 学习一番线段树的历史标记- 这道题就是区间加法,区间赋值,要询问区间最大值 和 区间历史最大值的最大值. 然后这种题就是在现有标记的基础上多弄一套标记,维护这个点出现过的最大的标 ...

  8. 解决Error: ENOENT: no such file or directory, scandir 安装node-sass报错

    新项目开发需要安装依赖,但是安装完之后通过gulp运行项目,产生了一下的报错: 解决方案是执行一些方法: npm rebuild node-sass 可是有时就是网络问题导致上面命令安装失败,查下失败 ...

  9. 【Demo】jQuery 图片放大镜效果——模仿淘宝图片放大效果

    实现功能: 模仿淘宝图片放大效果,鼠标移动到小图片的某一处,放大镜对应显示大图片的相应位置. 实现效果: 实现代码: <!DOCTYPE html> <html> <he ...

  10. Java网络编程和NIO详解6:Linux epoll实现原理详解

    Java网络编程和NIO详解6:Linux epoll实现原理详解 本系列文章首发于我的个人博客:https://h2pl.github.io/ 欢迎阅览我的CSDN专栏:Java网络编程和NIO h ...