《DSP using MATLAB》Problem 2.4
生成并用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的更多相关文章
- 《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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- SQL 根据条件取不同列中的值来排序
1 有时候排序比较复杂,比如:领导对工资在1000到2000元之间的员工更感兴趣,于是要求工资在这个范围内的员工排在前面,以便优先查看 对于这种要求我们可以在查询中新生成一列,用多列排序的方法处理代 ...
- 20145307陈俊达《网络对抗》Exp2 后门原理与实践
20145307陈俊达<网络对抗>Exp2 后门原理与实践 基础问题回答 例举你能想到的一个后门进入到你系统中的可能方式? 非正规网站下载的软件 脚本 或者游戏中附加的第三方插件 例举你知 ...
- 20155201 实验三《Java面向对象程序设计》实验报告
20155201 实验三<Java面向对象程序设计>实验报告 一.实验内容 XP基础 XP核心实践 相关工具 二.实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门 ...
- 20145204 《Java程序设计》第2周学习总结
20145204 <Java程序设计>第2周学习总结 教材学习内容总结 在第三章主要学习了Java语言中的类型及其变量主要类型为:整数(1字节的byte,2字节的short,4字节的int ...
- HeyWeGo第四周项目总结
HeyWeGo第四周项目总结 项目内容 使用java程序开发一款扫雷游戏 游戏项目规划: 确定游戏中方块格子的个数 确定游戏中地雷的个数(初始10个),完成布雷 计算每个方块周围的雷数,在方块周围本身 ...
- CSS3动画库——animate.css
初见animate.css的时候,感觉很棒,基本上很多常用的CSS3动画效果都帮我们写好了,所以想要哪一种效果直接就可以拿过来用,甚是方便: 效果展示官网:http://daneden.github. ...
- socket可读可写就绪条件
参考 <UNIX 网络编程卷1>中的<第6章 I/O复用> 一. 满足下列四个条件中的任何一个时,一个套接字准备好读. 该套接字接收缓冲区中的数据字节数大于等于套接字接收缓存区 ...
- Facade(外观)
意图: 为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 适用性: 当你要为一个复杂子系统提供一个简单接口时.子系统往往因为不断演化而变 ...
- Rails Guide -- Ruby on Rake(未详细阅读)
一个软件task管理和build 自动化的工具. 它允许用户指定tasks和describe dependencies, 也可以在一个namespace中group tasks. 使用Ruby语言写的 ...
- Android-----------广告图片轮播控件
Banner广告图片轮播控件,支持无限循环和多种主题,可以灵活设置轮播样式.动画.轮播和切换时间.位置.图片加载框架等! 很多Android APP中都有广告栏,我也用过很多次了,特来写一篇博文. 先 ...