《DSP using MATLAB》Problem 5.34
第1小题
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.34 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------------
% X(k) is DFTs of real-valued sequence x(n)
% x(n)=A*cos(2*pi*l*n/N) n=[0:N-1]
%
% 1 x1(n) = 3cos(0.04*pi*n) n=[0:200-1]
% -------------------------------------------------------------------------------------
N = 200; l = 2;
n1 = [0:N-1];
x1 = 3*cos(2*pi*l*n1/100); figure('NumberTitle', 'off', 'Name', 'P5.34.1 x(n), N=200')
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x(n)');
title('x(n)=3cos(0.04*pi*n)'); grid on; k1 = [0:N-1];
Xk_DFT = fft(x1, N);
N1 = length(Xk_DFT); % length magXk_DFT = abs( [ Xk_DFT ] ); % DFT magnitude
angXk_DFT = angle( [Xk_DFT] )/pi; % DFT angle
realXk_DFT = real(Xk_DFT); imagXk_DFT = imag(Xk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.34.1 X(k), DFT of x(n) N=200')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of x(n)'); grid on;
subplot(2,2,3); stem(k1, angXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of x(n)'); grid on;
subplot(2,2,2); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n)'); grid on;
subplot(2,2,4); stem(k1, imagXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of x(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.34.1 real X(k), N=200')
set(gcf,'Color','white');
stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n)'); grid on;
运行结果:
N=200个样点共包含4个周期:
序列的DFT
DFT的实部序列
由上图可知,有两条孤立谱线,位于k=L=4和k=N-L=200-4=196处,幅度值AN/2=3×200/2=300。
《DSP using MATLAB》Problem 5.34的更多相关文章
- 《DSP using MATLAB》Problem 8.34
今天下了小雨,空气中泛起潮湿的味道,阴冷的感觉袭来,心情受到小小影响. 代码: hp2lpfre子函数 function [wpLP, wsLP, alpha] = hp2lpfre(wphp, ws ...
- 《DSP using MATLAB》Problem 7.34
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.35
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《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 ...
随机推荐
- learning ddr mode register MR2
- how to get ubuntu current default runlevel
[Purpose] Learning how to get ubuntu current default runlevel [Eevironment] Ubuntu 1 ...
- unity中自制模拟第一人称视角
public float sensitivityX = 5f; public float sensitivityY = 5f; public float sensitivetyKeyBoard = 0 ...
- 理解AXI Quad Serial Peripheral Interface(SPI) IP核
reference : PG153-AXI Quad SPI v3.2 LogiCORE IP Product Guide.pdf 在使用MicroBlaze过程中,调用了此IP,所以有必须仔细学 ...
- Android开发 ---Activity的7种运行状态
Android开发 ---Activity的7种运行状态 创建 --> 启动 --> 运行 --> 暂停 --> 停止 --> 销毁 重启 操作图解: 1.MainA ...
- Java进程和线程
进程是资源分配和任务调度的基本单位, 进程就是包含上下文切换的程序执行时间总和=CPU加载上下文环境+CPU执行+CPU保存上下文环境,可以理解为时间片段: 进程的颗粒度太大了,将进程分块,按照a,c ...
- 关于makefile的生成原理以及make相关命令的使用
一.生成configure过程中各文件之间的关系图 二.详细介绍 autoscan: 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是con ...
- 接口的鉴权&响应数据解密
前言: 1.开放的接口为了避免被别人攻击,频繁刷接口,浪费服务器资源,这就涉及到签名(Signature)加密了 2.API 使用签名方法(Signature)对接口进行鉴权(Authenticati ...
- Flask源码阅读-第三篇(flask\_compat.py)
源码 # -*- coding: utf-8 -*-""" flask._compat ~~~~~~~~~~~~~ Some py2/py3 compatibility ...
- python 正则进阶
1.group 除了简单地判断是否匹配之外,正则表达式还有提取子串的强大功能.用()表示的就是要提取的分组(Group).比如:^(\d{3})-(\d{3,8})$分别定义了两个组,可以直接从匹配的 ...