《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
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- 【2】IOS APP打包发布
目的: 本文的目的是对IOS APP打包发布做了对应的介绍,大家可根据文档步骤进行mac环境部署: 申请苹果开发者账号 此处略 创建申请证书 这样做的目的就是为你的电脑安装发布许可证,只有这样你的电脑 ...
- day31-python阶段性复习五
打印目录下所有文件 os 模块 os.listdir(‘/home’) 列出目录下所有文件 os.path.isdir(‘/home’) 判断一个文件是不是一个目录 os.path.isfile(‘/ ...
- 前端vue项目-关于下载文件pdf/excel(三)
最近在做一些需求,需要下载一些文件信息,最频繁的就是下载excel文件到本地了 看过了很多方法,做个整理吧哈哈哈哈 参考的文章链接: https://www.cnblogs.com/jiangweic ...
- caffe blob
Blob,包括输入数据.输出数据.权值等: Blob是Caffe中处理和传递实际数据的数据封装包,并且在CPU与GPU之间具有同步处理能力.从数学意义上说,blob是按C风格连续存储的N维数组. ca ...
- DevExpress WinForms使用教程:Diagram Control
[DevExpress WinForms v18.2下载] DevExpress WinForms v18.2包含WinForms和WPF Diagram Controls的三个高要求功能:新的Dia ...
- DevExpress v18.1新版亮点——DevExtreme篇(四)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExtreme JavaScript Controls v18.1 的新功能 ...
- kettle在linux下执行任务
1.下载 最新版下载 7.1 https://community.hitachivantara.com/docs/DOC-1009855 准备 上传任务文件 .kjb,.ktr 上传mysql 驱动 ...
- tensorflow-softmax
之前在softmax多分类中讲到多用交叉熵作为损失函数,这里顺便写个例子,tensorlflow练手. # encoding:utf-8 import tensorflow as tf import ...
- 基于spec互评Alpha版本
作业要求[https://edu.cnblogs.com/campus/nenu/2018fall/homework/2323] 队名:二次元梦之队 组长:刘莹莹 组员:周昊 潘世维 王玉潘 赵美增 ...
- jQuery中$的三种关系
要搞清楚$('div','li') 和 $('div , li') 和 $('div li') 区别 $('div','li')是$(子,父),是从父节点里找子,而不是找li外面的div $('div ...