生成并用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. Hadoop mapreduce自定义排序WritableComparable

    本文发表于本人博客. 今天继续写练习题,上次对分区稍微理解了一下,那根据那个步骤分区.排序.分组.规约来的话,今天应该是要写个排序有关的例子了,那好现在就开始! 说到排序我们可以查看下hadoop源码 ...

  2. Python Missing parentheses in call to 'print'

    原来是因为Python2.X和Python3.X不兼容. 我安装的是Python3.X,但是我试图运行的却是Python2.X 的代码. 所以上面的语法在python3中是错误的.在python3中, ...

  3. Python笔记 #07# NumPy 文档地址 & Subsetting 2D Arrays

    文档地址:np.array() 1.<class 'numpy.ndarray'> ndarray 表示 n 维度(n D)数组 (= n 行数组). 2.打印 array 结构 —— n ...

  4. P3327/bzoj3994 [SDOI2015]约数个数和(莫比乌斯反演)

    P3327 [SDOI2015]约数个数和 神犇题解(转) 无话可补 #include<iostream> #include<cstdio> #include<cstri ...

  5. 关于Cooperation.GTST

    Cooperation.GTST团队项目简介 我们打算利用Android Studio开发一款博客园的Android APP,初步设想能够实现在Android手机平台使用博客园的相关功能,后续想法会在 ...

  6. STM32.ADC

    ADC实验 原理图: 1.ADC配置函数 /* enable adc1 and config adc1 to dma mode */ ADC1_Init(); /** * @brief ADC1初始化 ...

  7. LSB含义

    LSB(Least Significant Bit)最低有效位,对任何AD来说,量化后输出的数字信号值都是以1LSB的电压值步进的,介于1LSB之间的电压将按照一定的规则进行入位或舍弃,这个过程中造成 ...

  8. SpringMVC整个执行流程

    在SSM (或SSH) 框架整合使用后,基本骨架看上去还是MVC的结构. MyBatis整合一些数据封装方法节省了DAO层的代码量, Spring提供了AOP,IoC( DI 具体实现 ). 而Spr ...

  9. java虚拟机类加载

    java虚拟机中类的加载 (JVM的大致结构图) 从发class文件到内存中的类,按先后顺序,需要经过加载,链接以及初始化三大步骤. java语言的类型可分为两大类:基本类型(primitive ty ...

  10. Coursera SDN M1.1 SDN History: Central Control

    source Structure 1.讨论SDN的时间线,从1980s至今. 2.认识到SDN背后的原则和idea. 3.识别SDN起源的架构主题. NOTE Four Chapter in SDN ...