《DSP using MATLAB》 Problem 2.3

本题主要是显示周期序列的。
1、代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.3.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);
%% ------------------------------------------------------------------------ %%
%% {...,-2,-1,0,1,2,...}
%% *
%% Plot 5 periods
self_length = 5;
periods = 5; n = [-2:(2+(periods-1) * self_length)];x = [-2,-1,0,1,2];
xtilde = x' * ones(1,periods); xtilde = (xtilde(:))'; figure('NumberTitle', 'off', 'Name', 'Problem 2.3.1');
set(gcf,'Color','white');
stem(n,xtilde); title('Sequence in Problem 2.3.1');
xlabel('n'); ylabel('xtilde(n)');grid on;
显示结果:

2、代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.3.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);
%% ------------------------------------------------------------------------ %%
%% exp(0.1n)[ u(n) - u(n-20)] 0-20 valid
%%
%% Plot 3 periods [0;3*20-1] [0,59] n = [0:20]; % We can get self_periods=21 from here
x = exp(0.1*n) .* (stepseq(0,0,20) - stepseq(20,0,20));
%x = (stepseq(0,0,20) - stepseq(20,0,20)); figure('NumberTitle', 'off', 'Name', 'Problem 2.3.2 x(n)');
set(gcf,'Color','white');
stem(n,x); title('x(n) Sequence');
xlabel('n'); ylabel('x(n)');grid on; self_length = 21;
periods = 3;
n1 = [0:20 + (periods-1) * self_length]; xtilde = x' * ones(1,periods); xtilde = (xtilde(:))'; figure('NumberTitle', 'off', 'Name', 'Problem 2.3.2');
set(gcf,'Color','white');
stem(n1,xtilde); title('Sequence in Problem 2.3.2');
xlabel('n'); ylabel('xtilde(n)');grid on;
运行结果:


3、代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.3.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);
%% ------------------------------------------------------------------------ %%
%% sin(0.1*pi*n)[ u(n) - u(n-10)] 0-10 valid
%%
%% Plot 4 periods n = [0:10]; % We can get self_periods=11 from here
x = sin(0.1*pi*n) .* (stepseq(0,0,10) - stepseq(10,0,10)); figure('NumberTitle', 'off', 'Name', 'Problem 2.3.3 x(n)');
set(gcf,'Color','white');
stem(n,x); title('x(n) Sequence');
xlabel('n'); ylabel('x(n)');grid on; self_length = 11;
periods = 4;
n1 = [0:10 + (periods-1) * self_length]; xtilde = x' * ones(1,periods); xtilde = (xtilde(:))'; figure('NumberTitle', 'off', 'Name', 'Problem 2.3.3');
set(gcf,'Color','white');
stem(n1,xtilde); title('Sequence in Problem 2.3.3');
xlabel('n'); ylabel('xtilde(n)');grid on;
运行结果:


4、代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 2.3.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);
%% ------------------------------------------------------------------------ %%
%% {...,1,2,3,...} + {...,1,2,3,4,...} n=[0:24]
%% * *
%% what is the periods self_length1 = 3;
periods1 = 8; n1 = [0:(2+(periods1-1) * self_length1)];
x1 = [1, 2, 3];
xtilde1 = x1' * ones(1,periods1); xtilde1 = (xtilde1(:))'; figure('NumberTitle', 'off', 'Name', 'Problem 2.3.4 Period Seq 1');
set(gcf,'Color','white');
stem(n1,xtilde1); title('Sequence {...,1,2,3,...}');
xlabel('n'); ylabel('xtilde1(n)');grid on; self_length2 = 4;
periods2 = 6; n2 = [0:(3+(periods2-1) * self_length2)];
x2 = [1, 2, 3, 4];
xtilde2 = x2' * ones(1,periods2); xtilde2 = (xtilde2(:))'; figure('NumberTitle', 'off', 'Name', 'Problem 2.3.4 Period Seq 2');
set(gcf,'Color','white');
stem(n2,xtilde2); title('Sequence {...,1,2,3,4,...}');
xlabel('n'); ylabel('xtilde2(n)');grid on; x = xtilde1 + xtilde2
%[x,n] = sigadd(xtilde1,24,xtilde2,24); figure('NumberTitle', 'off', 'Name', 'Problem 2.3.4');
set(gcf,'Color','white');
stem(x); title('Sequence {...,1,2,3,...} + {...,1,2,3,4,...}');
xlabel('n'); ylabel('x(n)');grid on;
运行结果:




《DSP using MATLAB》 Problem 2.3的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- python学习之【16】网络编程
主题 客户端/服务器架构 套接字:通信终点 套接字地址 面向连接与无连接套接字 Python中的网络编程 SOCKET模块 套接字对象方法 TCP/IP客户端和服务器 UDP/IP客户端和服务器 So ...
- ng-深度学习-课程笔记-4: 浅层神经网络(Week3)
1 神经网络概览( Neural Networks Overview ) 先来快速过一遍如何实现神经网络. 首先需要输入特征x,参数w和b,计算出z,然后用激活函数计算出a,在神经网络中我们要做多次这 ...
- P1122 最大子树和(树形dp)
P1122 最大子树和 大水题 随便找一个点做根,蓝后累计子树和. 子树和<0的话不取就行了 顺便找个最大值输出 end. #include<iostream> #include&l ...
- Python3.x:简单时间调度Timer(间隔时间执行)
Python3.x:简单时间调度Timer(间隔时间执行) threading模块中的Timer能够帮助实现定时任务,而且是非阻塞的: 代码: import threading import time ...
- phpstorm 代码片段使用方法
原文链接: http://wwwquan.com/show-66-121-1.html 4.Live Templates代码片断 A)我们先介绍一个代码片段最基本的功能,我们要实现的目标是在html文 ...
- linux内核分析第四周-使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
本周作业的主要内容就是采用gcc嵌入汇编的方式调用system call.系统调用其实就是操作系统提供的服务.我们平时编写的程序,如果仅仅是数值计算,那么所有的过程都是在用户态完成的,但是我们想将变量 ...
- linux第四章读书笔记
第四章 进程调度 一.多任务 多任务操作系统就是能同时并发的交互执行多个进程的操作系统.多任务操作系统使多个进程处于堵塞或者睡眠状态,实际不被投入执行,这些任务尽管位于内存,但是并不处于可运行状态.多 ...
- stm32 Flash读写独立函数[库函数]
一. stm32的FLASH分为 1.主存储块:用于保存具体的程序代码和用户数据,主存储块是以页为单位划分的, 一页大小为1KB.范围为从地址0x08000000开始的128KB内. 2.信息块 ...
- SQL 中 not in 查询不到数据问题
在开发的过程中,遇到过not in 始终查询不到数据问题 select * from T_CustomerInfo where CustomerID not in (select CustomerID ...
- [BZOJ3237]连通图
Description Input Output Sample Input 4 5 1 2 2 3 3 4 4 1 2 4 3 1 5 2 2 3 2 1 2 Sample Output Connec ...