《DSP using MATLAB》Problem 5.21
证明:
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.21 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ---------------------------------------------------------------------------------
%
% Parseval relation
% sum[abs(x(n))^2] = sum[abs(X(k))^2]/N
%
% ---------------------------------------------------------------------------------
n = [0:10];
x = [5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4]; % N=11 sequence
N = length(x); Exn = sum(abs(x).^2) m1 = -5; N1 = 12;
n1 = [0:N1-1]; m2 = 8; N2 = 15;
n2 = [0:N2-1]; % -----------------------------------------------------
% 1st way to get circular shift---time domain
% -----------------------------------------------------
y1_1 = cirshftt(x, m1, N1);
y2_1 = cirshftt(x, m2, N2); % --------------------------------------------------------
% 2rd way to get circular shift --- freq domain
% --------------------------------------------------------
y1_2 = cirshftf(x, m1, N1);
y2_2 = cirshftf(x, m2, N2); figure('NumberTitle', 'off', 'Name', 'P5.21.a x(n) and its cir shift')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, x);
xlabel('n'); ylabel('x(n)');
title('x(n), N=11'); grid on;
subplot(3,1,2); stem(n1, y1_1);
xlabel('n'); ylabel('y(n)');
title('TIME domain circular shift x(n), m=-5, N=12'); grid on;
subplot(3,1,3); stem(n1, y1_2);
xlabel('n'); ylabel('y(n)');
title('FREQ domain circular shift x(n), m=-5, N=12'); grid on;
axis([0, N1, 0, 6]); figure('NumberTitle', 'off', 'Name', 'P5.21.b x(n) and its cir shift')
set(gcf,'Color','white');
subplot(3,1,1); stem(n, x);
xlabel('n'); ylabel('x(n)');
title('x(n), N=11'); grid on;
subplot(3,1,2); stem(n2, y2_1);
xlabel('n'); ylabel('y(n)');
title('TIME domain circular shift x(n), m=8, N=15'); grid on;
subplot(3,1,3); stem(n2, y2_2);
xlabel('n'); ylabel('y(n)');
title('FREQ domain circular shift x(n), m=8, N=15'); grid on;
axis([0, N2-1, 0, 6]); % ----------------------------------------------------
% DFT of sequence
% ---------------------------------------------------- Xk_DFT = dft(x, N);
k = n; 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); EXk = sum(magXk_DFT .^ 2)/N Y11k_DFT = dft(y1_1, N1);
k1 = n1; magY11k_DFT = abs( [ Y11k_DFT ] ); % DFT magnitude
angY11k_DFT = angle( [Y11k_DFT] )/pi; % DFT angle
realY11k_DFT = real(Y11k_DFT);
imagY11k_DFT = imag(Y11k_DFT); EY11k = sum(magY11k_DFT.^2)/N1 Y21k_DFT = dft(y2_1, N2);
k2 = n2; magY21k_DFT = abs( [ Y21k_DFT ] ); % DFT magnitude
angY21k_DFT = angle( [Y21k_DFT] )/pi; % DFT angle
realY21k_DFT = real(Y21k_DFT);
imagY21k_DFT = imag(Y21k_DFT); EY21k = sum(magY21k_DFT.^2)/N2 figure('NumberTitle', 'off', 'Name', 'P5.21 X(k), DFT of x(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k, magXk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of x(n), N=11'); grid on;
subplot(2,2,3); stem(k, angXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of x(n), N=11'); grid on;
subplot(2,2,2); stem(k, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n), N=11'); grid on;
subplot(2,2,4); stem(k, imagXk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of x(n), N=11'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.21 Y11(k), DFT of x((n+5))12')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magY11k_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of y11(n), N=12'); grid on;
subplot(2,2,3); stem(k1, angY11k_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of y11(n), N=12'); grid on;
subplot(2,2,2); stem(k1, realY11k_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of y11(n), N=12'); grid on;
subplot(2,2,4); stem(k1, imagY11k_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of y11(n), N=12'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.21 Y21(k), DFT of x((n-8))15')
set(gcf,'Color','white');
subplot(2,2,1); stem(k2, magY21k_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of y21(n), N=15'); grid on;
subplot(2,2,3); stem(k2, angY21k_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of y21(n), N=15'); grid on;
subplot(2,2,2); stem(k2, realY21k_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of y21(n), N=15'); grid on;
subplot(2,2,4); stem(k2, imagY21k_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of y21(n), N=15'); grid on;
运行结果:
序列的圆周移位
原始序列x(n)的DFT
圆周移位序列1的DFT
圆周移位序列2的DFT
上图可知,时域的能量和频域的能量相等。
《DSP using MATLAB》Problem 5.21的更多相关文章
- 《DSP using MATLAB》Problem 6.21
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.21
快到龙抬头,居然下雪了,天空飘起了雪花,温度下降了近20°. 代码: %% -------------------------------------------------------------- ...
- 《DSP using MATLAB》Problem 8.21
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 3.21
模拟信号经过不同的采样率进行采样后,得到不同的数字角频率,如下: 三种Fs,采样后的信号的谱 重建模拟信号,这里只显示由第1种Fs=0.01采样后序列进行重建,采用zoh.foh和spline三种方法 ...
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《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
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- 1.python函数式编程-map函数
编程方法论 面向过程 函数式 面向对象 面向过程 将编程过程拆分成多个步骤,在函数中按照每个步骤进行编程: 函数式编程 编程语言定义的函数+数学意义的函数 1.不可变,不用变量保存状态,不修改变量: ...
- 常用6种type的form表单的input标签分析及示例
<input> 标签用于搜集用户信息. 根据不同的 type 属性值,输入字段拥有很多种形式.输入字段可以是文本字段.复选框.掩码后的文本控件.单选按钮.按钮等等. 在这里博主介绍6中ty ...
- loaclStorage、sessionStorage
这里需要注意的是这两种储存方式只能以字符串的形式来存取 html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage.sessionStorage用于 ...
- Oracle 12c的自增列Identity Columns
在Oracle的12c版本中,Oracle实现了类似MySQL中的auto_increment的自增列,下面我们看一起Oracle是怎么实现的. Oracle Database 12c Enterpr ...
- el表达式原样输出,不被解析
今天遇到了,在jar包都有的前提下EL表达式原样输出,不被解析,原因是: page指令中确少 isELIgnored="false" 加上就好了 <%@ page langu ...
- javascript进阶笔记(1)
学习js已经有一段时间了,大大小小还是能够做出一些东西来.不过觉得可惜的是,还是对js本身这门语言不是很熟悉,总有一点雾里看花的感觉,看得见,但是看不清楚.最近发现有一本关于js的叫做<忍者秘籍 ...
- htmlayout 最简单的实践,用于理解实现原理。
/ testHtmlayout.cpp : 定义应用程序的入口点. // #include "stdafx.h" #include "testHtmlayout.h&qu ...
- FindResource () RT_HTML 为什么总是出错呢 ?
#include <windows.h> #include <commdlg.h> #include <ole2.h> BOOL GetHtmlResource(L ...
- Linux:软件包安装
软件包安装 一.rpm安装 1.挂载系统:mount /dev/cdrom/ /mnt/cdrom/ 2.进入相应的目录(Centos7 为Packages,有一些是Server):cd /mnt/c ...
- C#窗体的浮动及隐藏
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...