《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- CCPC2018-湖南全国邀请赛 Solution
A - Easy $h$-index 后缀扫一下 #include <bits/stdc++.h> using namespace std; #define ll long long #d ...
- python uwsgi报错epoll_ctl(): Bad file descriptor
今天安装了uwsgi+supervisord+nginx,一直访问不了 直接启动uwsgi使用nginx访问,查看有大量报错:epoll_ctl(): Bad file descriptor [cor ...
- 【运维技术】Nginx安装教程(yum安装,源码编译)
安装方式 yum直接更新源安装 源码直接编译之后安装 使用yum进行直接安装 Installing a Prebuilt CentOS/RHEL Package from an OS Reposito ...
- Python3.x的BeautifulSoup解析html常用函数
Python3.x的BeautifulSoup解析html常用函数 1,初始化: soup = BeautifulSoup(html) # html为html源代码字符串,type(html) == ...
- 基于梯度场和Hessian特征值分别获得图像的方向场
一.我们想要求的方向场的定义为: 对于任意一点(x,y),该点的方向可以定义为其所在脊线(或谷线)位置的切线方向与水平轴之间的夹角: 将一条直线顺时针或逆时针旋转 180°,直线的方向保持不变. 因 ...
- 20145219《网络对抗》Web基础
20145219<网络对抗>Web基础 基础问题回答 什么是表单? HTML表单用于收集用户输入,用<form>元素定义,包含不同类型的 input元素.复选框.单选按钮.提交 ...
- 20145325张梓靖 《Java程序设计》第1周学习总结
20145325张梓靖 <Java程序设计>第1周学习总结 教材学习内容总结 JAVA三大平台:Java SE.Java EE .Java ME Java SE四个组成部分:JVM .JR ...
- 导入tensorflow:ImportError: libcublas.so.9.0: cannot open shared object file: No such file or director【转】
本文转载自:https://blog.csdn.net/ksws0292756/article/details/80034086 版权声明:本文为博主原创文章,转载请一定附上博主原文链接,并署名转自Z ...
- ExtJS发送POST请求 参数格式为JSON
背景 这要从我比较懒说起.技术框架ExtJS + resteasy,默认请求方式是ajax get,这后台方法就要写很多@QueryParam来获取参数.我比较喜欢前台用ajax post请求,后台方 ...
- HDU 6354 Everything Has Changed(余弦定理)多校题解
题意:源点处有个圆,然后给你m个圆(保证互不相交.内含),如果源点圆和这些原相交了,就剪掉相交的部分,问你最后周长(最外面那部分的长度). 思路:分类讨论,只有内切和相交会变化周长,然后乱搞就行了.题 ...