《DSP using MATLAB》Problem 3.3
按照题目的意思需要利用DTFT的性质,得到序列的DTFT结果(公式表示),本人数学功底太差,就不写了,直接用
书中的方法计算并画图。
代码:
%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.3 \n\n'); banner();
%% ------------------------------------------------------------------------ % ----------------------------------
% x1(n)
% ----------------------------------
n1_start = -3; n1_end = 13;
n1 = [n1_start : n1_end]; x1 = (2 * 0.5.^ (n1)) .* stepseq(-2, n1_start, n1_end); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 x1(n)');
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x1');
title('x1(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X1] = dtft(x1, n1, w); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 DTFT of x1(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX1); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX1); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); X1_chk = 8*exp(j*2*w) + 4*exp(j*w) + 2 ./ (1-0.5*exp(-j*w));
magX1_chk = abs(X1_chk); angX1_chk = angle(X1_chk); realX1_chk = real(X1_chk); imagX1_chk = imag(X1_chk); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 X1(w) by formular');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX1_chk); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX1_chk); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % -------------------------------------
% x2(n)
% -------------------------------------
n2_start = -9; n2_end = 15;
n2 = [n2_start : n2_end]; x2 = (0.6 .^ (abs(n2))) .* (stepseq(-10, n2_start, n2_end) - stepseq(11, n2_start, n2_end)); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 x2(n)');
set(gcf,'Color','white');
stem(n2, x2);
xlabel('n'); ylabel('x2');
title('x2(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X2] = dtft(x2, n2, w); magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 DTFT of x2(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX2); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX2); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % -------------------------------------
% x3(n)
% -------------------------------------
n3_start = -3; n3_end = 10;
n3 = [n3_start : n3_end]; x3 = ( n3 .* (0.9 .^ (n3))) .* stepseq(-3, n3_start, n3_end); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 x3(n)');
set(gcf,'Color','white');
stem(n3, x3);
xlabel('n'); ylabel('x3');
title('x3(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X3] = dtft(x3, n3, w); magX3 = abs(X3); angX3 = angle(X3); realX3= real(X3); imagX3 = imag(X3); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 DTFT of x3(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX3); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX3); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % -------------------------------------
% x4(n)
% -------------------------------------
n4_start = 0; n4_end = 50;
n4 = [n4_start : n4_end]; x4 = (n4 + 3) .* (0.8 .^ (n4-1)) .* stepseq(2, n4_start, n4_end); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 x4(n)');
set(gcf,'Color','white');
stem(n4, x4, 'r', 'filled');
xlabel('n'); ylabel('x4');
title('x4(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X4] = dtft(x4, n4, w); magX4 = abs(X4); angX4 = angle(X4); realX4= real(X4); imagX4 = imag(X4); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 DTFT of x4(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX4); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX4); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % -------------------------------------
% x5(n)
% -------------------------------------
n5_start = 0; n5_end = 30;
n5 = [n5_start : n5_end]; x5 = 4 * (-7 .^ (n5)) .* cos(0.25*pi*n5) .* stepseq(0, n5_start, n5_end); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 x5(n)');
set(gcf,'Color','white');
stem(n5, x5, 'r', 'filled');
xlabel('n'); ylabel('x5');
title('x5(n) sequence'); grid on; M = 500;
k = [-M:M]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/M) * k; [X5] = dtft(x5, n5, w); magX5 = abs(X5); angX5 = angle(X5); realX5= real(X5); imagX5 = imag(X5); figure('NumberTitle', 'off', 'Name', 'Problem 3.3 DTFT of x5(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX5); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX5); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians');
运行结果:
1、原始序列及其DTFT
2、
3、
4、
5、
《DSP using MATLAB》Problem 3.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窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- CCPC-Wannafly Winter Camp Day5 (Div2, onsite)
Replay: Dup4: 时间复杂度算不对? 一点点思路不经过验证就激动的要死? 浪费自己一个小时还浪费别人一个小时? 对1e3不敏感? 1e3 * 1e3是多少? 模拟建边跑dp不写非要写个大模拟 ...
- Learning to Rank之Ranking SVM 简介
排序一直是信息检索的核心问题之一,Learning to Rank(简称LTR)用机器学习的思想来解决排序问题(关于Learning to Rank的简介请见我的博文Learning to Rank简 ...
- 【转载】open-falcon部署
运维监控系统之Open-Falcon 一.Open-Falcon介绍 1.监控系统,可以从运营级别(基本配置即可),以及应用级别(二次开发,通过端口进行日志上报),对服务器.操作系统.中间件.应用 ...
- 文件名含中文的JavaWeb文件下载
在javaweb项目中实现文件下载,当文件名中包含中文文字时,需要进行如下的处理,才能在浏览器端正常显示中文文件名: response.setContentType("octets/stre ...
- JS在if中的强制类型转换
JS在if中的强制类型转换 众所周知,JS在很多情况下会进行强制类型转换,其中,最常见两种是: 1.使用非严格相等进行比较,对==左边的值进行类型转换 2.在if判断时,括号内的值进行类型转换,转化为 ...
- 钉钉,连续获取Token一样么? Js_ticket重复获取一样么?
经过测试,是一样的: Token的过期时间是2个小时: 2个小时后在获取则发生变化: js_ticket: 重复获取的值不同的:
- mongodb的存储引擎
mongodb版本为3.4 mongodb存储引起的一些概述 存储引擎是MongoDB的核心组件,负责管理数据如何存储在硬盘和内存上.从MongoDB 3.2 版本开始,MongoDB 支持多数据存储 ...
- 20145307陈俊达《网络对抗》逆向及Bof基础
20145307陈俊达<网络对抗>逆向及Bof基础 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任 ...
- 20145329 《网络对抗技术》PC平台逆向破解
shellcode注入 实践是在非常简单的一个预设条件下完成的: (1)关闭堆栈保护 (2)关闭堆栈执行保护 (3)关闭地址随机化 (4)在x32环境下 (5)在Linux实践环境 shellcode ...
- 20135320赵瀚青LINUX第八周学习笔记
赵瀚青原创作品转载请注明出处<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 概述 本周学习的是linux ...