生成并用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. 牛客国庆集训派对Day2 Solution

    A    矩阵乘法 思路: 1° 牛客机器太快了,暴力能过. #include <bits/stdc++.h> using namespace std; #define N 5000 in ...

  2. FFmpeg 入门(7):Seeking

    本文转自:FFmpeg 入门(7):Seeking | www.samirchen.com 处理 seek 命令 我们将为播放器添加 seek 的能力.这个过程中,我们会看到 av_seek_fram ...

  3. WebApi_返回Post格式数据

    [HttpPost] public HttpResponseMessage Post([FromBody] DingTalkCallBack bodyMsg, string signature, st ...

  4. [BZOJ1901]Dynamic Rankings

    Description 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1 ],a[i+2]……a[j]中第k小的数 ...

  5. Codeforces Round #390 (Div. 2) A. Lesha and array splitting

    http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...

  6. Hive安装-windows(转载)

    1.安装hadoop 2.从maven中下载mysql-connector-java-5.1.26-bin.jar(或其他jar版本)放在hive目录下的lib文件夹 3.配置hive环境变量,HIV ...

  7. USB.资料

    1.百度搜索 “usb java” 1.1.基于usb4java实现的java下的usb通信 - tomi_mint - 博客园.html(https://www.cnblogs.com/sowhat ...

  8. PHP设计模式单例模式的继承实现

    最近在做O2O平台的接入,因为发现之前公司的代码里已经有了某家开放平台的接入代码,如果我再往原先的控制器上加入逻辑代码,整个控制器的耦合度会非常高.加上每个平台有自己的签名验证算法,把加解密的方法写到 ...

  9. 这些HTML、CSS知识点,面试和平时开发都需要 No10-No11(知识点:表格操作、代码编写规则)

    系列知识点汇总 1.基础篇 这些HTML.CSS知识点,面试和平时开发都需要 No1-No4(知识点:HTML.CSS.盒子模型.内容布局) 这些HTML.CSS知识点,面试和平时开发都需要 No5- ...

  10. MOBA游戏学会这些知识,你才算真的入门了!

    <英魂之刃口袋版>是一个标准的MOBA游戏,MOBA指的是多人在线战术竞技游戏,游戏模式始于1998年<星际争霸>中的一张自定义地图,经过近20年的优化和调整逐渐演变成了我们现 ...