《DSP using MATLAB》Problem 3.18
代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.18 \n\n'); banner();
%% ------------------------------------------------------------------------ %% -------------------------------------------------------------------
%% y(n)=x(n)+x(n-2)+x(n-4)+x(n-6)
%% -0.81y(n-2)-0.81*0.81y(n-4)-0.81^3*y(n-6)
%% -------------------------------------------------------------------
a = [1, 0, 0.81, 0, 0.81^2, 0, 0.81^3]; % filter coefficient array a
b = [1, 0, 1, 0, 1, 0, 1]; % filter coefficient array b MM = 500; [H, w] = freqresp1(b, a, MM); magH = abs(H); angH = angle(H); realH = real(H); imagH = imag(H); %% --------------------------------------------------------------------
%% START H's mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 3.18 H1');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magH); grid on; %axis([-1,1,0,1.05]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,1,2); plot(w/pi, angH/pi); grid on; axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 3.18 H1');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realH); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagH); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% --------------------------------------------------
%% x1(n)=5+10*(-1)^n
%% --------------------------------------------------
M = 200;
n1 = [0:M];
x1 = 5 + 10*(-1).^n1; y1 = filter(b, a, x1); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.1 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n1, x1);
xlabel('n'); ylabel('x1');
title(sprintf('x1(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n1, y1);
xlabel('n'); ylabel('y1');
title(sprintf('y1(n) output sequence, M = %d', M)); grid on; %% --------------------------------------------------
%% x2(n)=1+cos(0.5pin+pi/2)
%% -------------------------------------------------- n2 = n1;
x2 = 1 + cos(0.5*pi*n2+pi/2); y2 = filter(b, a, x2); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.2 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n2, x2);
xlabel('n'); ylabel('x');
title(sprintf('x2(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n2, y2);
xlabel('n'); ylabel('y');
title(sprintf('y2(n) output sequence, M = %d', M)); grid on; %% --------------------------------------------------
%% x3(n)=2sin(pin/4) + 3cos(3pin/4)
%% -------------------------------------------------- n3 = n1;
x3 = 2*sin(pi*n3/4) + 3*cos(3*pi*n3/2); y3 = filter(b, a, x3); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.3 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n3, x3);
xlabel('n'); ylabel('x');
title(sprintf('x3(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n3, y3);
xlabel('n'); ylabel('y');
title(sprintf('y3(n) output sequence, M = %d', M)); grid on; %% ------------------------------------------------------------------------------
%% x4(n)=1+2cos(pin/4)+3cos(2pin/4)+4cos(3pin/4)+5cos(4pin/4)+6cos(5pin/4)
%% ------------------------------------------------------------------------------ n4 = n1;
sum = 0;
for i = 0:5
sum = sum + (i+1)*cos(i*pi*n4/4);
end
x4 = sum; y4 = filter(b, a, x4); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.4 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n4, x4);
xlabel('n'); ylabel('x');
title(sprintf('x4(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n4, y4);
xlabel('n'); ylabel('y');
title(sprintf('y4(n) output sequence, M = %d', M)); grid on; %% -----------------------------------------------------------------
%% x5(n)=cos(pin)
%% ----------------------------------------------------------------- n5 = n1; x5 = cos(pi*n5); y5 = filter(b, a, x5); figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.5 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n5, x5);
xlabel('n'); ylabel('x');
title(sprintf('x5(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n5, y5);
xlabel('n'); ylabel('y');
title(sprintf('y5(n) output sequence, M = %d', M)); grid on; %% -----------------------------------------------------------------
%% x0(n)=Acos(w0n+theta)
%% -----------------------------------------------------------------
A = 3;
w0 = 0.2*pi;
theta = 0; n0 = n1; x0 = A * cos(w0*n0+theta); yss = filter(b, a, x0);
figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.18.6 M = %d',M));
set(gcf,'Color','white');
subplot(2,1,1);
stem(n0, x0);
xlabel('n'); ylabel('x');
title(sprintf('x0(n) input sequence, M = %d', M)); grid on;
subplot(2,1,2);
stem(n0, yss);
xlabel('n'); ylabel('y');
title(sprintf('yss(n) output sequence, M = %d', M)); grid on;
运行结果:
1、LTI系统的频率响应
第1小题:
第2小题:
第3小题:
第4小题:
第5小题:
《DSP using MATLAB》Problem 3.18的更多相关文章
- 《DSP using MATLAB》Problem 6.18
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.18
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...
- 《DSP using MATLAB》Problem 4.18
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 2.18
1.代码: function [y, H] = conv_tp(h, x) % Linear Convolution using Toeplitz Matrix % ----------------- ...
- 《DSP using MATLAB》Problem 8.18
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 5.15
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.15
只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
随机推荐
- angular2版本迭代之特性追踪
一. 2.0.0 升级到 2.4 升级前: 1.确保没有使用extends关键字实现OnInit的继承,以及没有用任何的生命周期中,而是全部改用implements. 2.停止使用deep impor ...
- Vue.js教程--基础(实例 模版语法template computed, watch v-if, v-show v-for, 一个组件的v-for.)
官网:https://cn.vuejs.org/v2/guide/index.html Vue.js 的核心是一个允许采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统. 视频教程:https: ...
- Sqlite3,维基百科中的练习:
https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store 两个相连的表格 Manufactures: code, name prod ...
- android------2018 年初值得关注的 16 个新 Android 库和项目
1. transitioner Transitioner 是一个为两个拥有嵌入子视图的视图之间提供简便.动态且可调整的动画效果的库.它纯 100% 使用 Kotlin 编写而成,使用 MIT 许可,且 ...
- Confluence 6 使用 LDAP 授权连接一个内部目录 - 拷贝用户到登录
在登录时拷贝用户(Copy User on Login) 这个选项在用户尝试登录的时候将会被触发.如果这个选择框被选择的话,当用户使用 LDAP 授权的用户名和密码登录系统的时候,用户将会在内部目录自 ...
- 利用nodeJs anywhere搭建本地服务器环境
1.npm install anywhere -g 如果是mac系统会提示你权限不够,需要在代码前加上 sudo获取管理员权限.即sudo npm install anywhere -g. 2.安装完 ...
- csp 通信网络
http://blog.csdn.net/zyy_1998/article/details/78334496 试题编号: 201709-4 试题名称: 通信网络 时间限制: 1.0s 内存限制: 25 ...
- Leetcode 78
//和77类似的问题,可以放在一起记忆class Solution { public: vector<vector<int>> subsets(vector<int> ...
- EBS R12 MOAC原理探索 (转)
转载地址 EBS R12 MOAC原理探索
- 图片上传--Upload
图片上传--Upload 图片上传基于spring框架写的代码: 1.首先:我们要再springmvc中添加试图解析器: <!-- 图片解析器 --> <bean id=" ...