《DSP using MATLAB》Problem 5.18


代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.18 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------------
% X(k) is 20-point DFTs of Complex-valued sequence x(n)
% X(k) = [3cos(0.2pi*k) + j4sin(0.1pi*k)][u(k)-u(k-20)]
% N = 20 k=[0:19]
%
% xccs = [x(n)+ x*((-n))]/2 xcca = [x(n) - x*((-n))]/2
% DFT[xccs] = real(X(k)) DFT[xcca] = j*imag(X(k))
% ------------------------------------------------------------------------------------- k1 = [0:19];
Xk_DFT = (3*cos(0.2*pi*k1) + j*4*sin(0.1*pi*k1)) .* (stepseq(0,min(k1),max(k1))-stepseq(20,min(k1),max(k1)));
N1 = length(Xk_DFT); % length is 10 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.18 X(k), DFT of x(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of x(n), N=20'); 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), N=20'); grid on;
subplot(2,2,2); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n), N=20'); 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), N=20'); grid on; [xn] = idft(Xk_DFT, N1); % Complex-valued sequence
n = [0 : N1-1]; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
% x(n) decomposition into circular-conjugate-symmetric and
% circular-conjugate-antisymmetric parts
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[xccs, xcca] = circevod_cv(xn); % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% DFT(k) of xccs and xcca, k=[0:N1-1]
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
k1 = [0:19]; Xk_CCS_DFT = dft(xccs, length(xccs));
Xk_CCA_DFT = dft(xcca, length(xcca)); N1 = length(Yk_DFT); % length is 10 magXk_CCS_DFT = abs( [ Xk_CCS_DFT ] ); % DFT magnitude
angXk_CCS_DFT = angle( [Xk_CCS_DFT] )/pi; % DFT angle
realXk_CCS_DFT = real(Xk_CCS_DFT);
imagXk_CCS_DFT = imag(Xk_CCS_DFT); magXk_CCA_DFT = abs( [ Xk_CCA_DFT ] ); % DFT magnitude
angXk_CCA_DFT = angle( [Xk_CCA_DFT] )/pi; % DFT angle
realXk_CCA_DFT = real(Xk_CCA_DFT);
imagXk_CCA_DFT = imag(Xk_CCA_DFT); figure('NumberTitle', 'off', 'Name', 'P5.18 DFT(k) of xccs(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXk_CCS_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of xccs(n), N=20'); grid on;
subplot(2,2,3); stem(k1, angXk_CCS_DFT);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of xccs(n), N=20'); grid on;
subplot(2,2,2); stem(k1, realXk_CCS_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of xccs(n), N=20'); grid on;
subplot(2,2,4); stem(k1, imagXk_CCS_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of xccs(n), N=20'); grid on; figure('NumberTitle', 'off', 'Name', 'P5.18 DFT(k) of xcca(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXk_CCA_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of xcca(n), N=20'); grid on;
subplot(2,2,3); stem(k1, angXk_CCA_DFT);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of xcca(n), N=20'); grid on;
subplot(2,2,2); stem(k1, realXk_CCA_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of xcca(n), N=20'); grid on;
subplot(2,2,4); stem(k1, imagXk_CCA_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of xcca(n), N=20'); grid on; % --------------------------------------------------------------
% Verify
% DFT[xccs] = real(X(k)) DFT[xcca] = j*imag(X(k))
% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.18 Verify')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real(k)');
title('real DFT of x(n), N=20'); grid on;
subplot(2,2,3); stem(k1, imagXk_DFT);
xlabel('k'); ylabel('imag(k)');
title('imag DFT of x(n), N=20'); grid on; subplot(2,2,2); stem(k1, realXk_CCS_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of xccs(n), N=20'); grid on;
subplot(2,2,4); stem(k1, imagXk_CCA_DFT);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of xcca(n), N=20'); grid on; error1 = sum( abs(realXk_DFT - realXk_CCS_DFT) )
error2 = sum( abs(imagXk_DFT - imagXk_CCA_DFT) ) % ----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.18 x(n) & xccs(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(n, real(xn));
xlabel('n'); ylabel('x(n)');
title('real[x(n)], IDFT of X(k)'); grid on;
subplot(2,2,2); stem(n, real(xccs));
xlabel('n'); ylabel('xccs(n)');
title('real xccs'); grid on; subplot(2,2,3); stem(n, imag(xn));
xlabel('n'); ylabel('x(n)');
title('imag[x(n)], IDFT of X(k)'); grid on;
subplot(2,2,4); stem(n, imag(xccs));
xlabel('n'); ylabel('xccs(n)');
title('imag xccs'); grid on; % ---------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.18 x(n) & xcca(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(n, real(xn));
xlabel('n'); ylabel('x(n)');
title('real[x(n)], IDFT of X(k)'); grid on;
subplot(2,2,2); stem(n, real(xcca));
xlabel('n'); ylabel('xcca(n)');
title('real xcca'); grid on; subplot(2,2,3); stem(n, imag(xn));
xlabel('n'); ylabel('x(n)');
title('imag[x(n)], IDFT of X(k)'); grid on;
subplot(2,2,4); stem(n, imag(xcca));
xlabel('n'); ylabel('xcca(n)');
title('imag xcca'); grid on;
运行结果:
20点DFT,X(k)

圆周共轭对称序列的DFT

圆周共轭反对称的DFT

从下图看出,序列的DFT X(k)的实部与圆周共轭对称分量的DFT的实部相等;
序列的DFT X(k)的虚部与圆周共轭反对称分量的DFT的虚部相等;

圆周共轭对称序列:xccs(n)

圆周共轭反对称序列xcca(n)

《DSP using MATLAB》Problem 5.18的更多相关文章
- 《DSP using MATLAB》Problem 6.18
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 4.18
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 3.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,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
随机推荐
- 尚学堂java 答案解析 第六章
本答案为本人个人编辑,仅供参考,如果读者发现,请私信本人或在下方评论,提醒本人修改 一.选择题 1.C 解析:对void下的函数,可以使用"return;"表示结束之意,但不能&q ...
- Java遍历集合的几种方法分析(实现原理、算法性能、适用场合)
概述 Java语言中,提供了一套数据集合框架,其中定义了一些诸如List.Set等抽象数据类型,每个抽象数据类型的各个具体实现,底层又采用了不同的实现方式,比如ArrayList和LinkedList ...
- 【转载】JVM系列三:JVM参数设置、分析
不管是YGC还是Full GC,GC过程中都会对导致程序运行中中断,正确的选择不同的GC策略,调整JVM.GC的参数,可以极大的减少由于GC工作,而导致的程序运行中断方面的问题,进而适当的提高Java ...
- 十五. Python基础(15)--内置函数-1
十五. Python基础(15)--内置函数-1 1 ● eval(), exec(), compile() 执行字符串数据类型的python代码 检测#import os 'import' in c ...
- core1.1 升级到 2.0
1.直接修改项目 1.1 改成 2.0 Startup 的修改 去除构造函数中下面的代码 var builder = new ConfigurationBuilder() .SetBasePath(e ...
- js如何调试,使用debug模式
js的代码断点调试非常简单,不需要借助代码编辑器,只要浏览器就行了(注意:html代码打断点是没有用的,只有js的才行,下图第二步打开开发者模式使用F12才对):
- ssm使用双数据源
工作中需要接入其他公司业务系统的数据进行分析,于是接入它们的db. 使用双数据源配置感觉如下: database.sessionFactory.扫描器.事务管理器等双份. 听说如果两个数据源需要一起使 ...
- Install SharePoint 2013 with SP1 on Windows Server 2012 R2 error - This Product requires .NF 4.5
博客地址:http://blog.csdn.net/FoxDave 最近因为项目需要要搭建SharePoint 2013的开发环境. 准备了Windows Server 2012 R2系统和Sha ...
- string使用方法
转载自:https://blog.csdn.net/tengfei461807914/article/details/52203202 使用场合: string是C++标准库的一个重要的部分,主要用于 ...
- 一个灵活的AssetBundle打包工具
尼尔:机械纪元 上周介绍了Unity项目中的资源配置,今天和大家分享一个AssetBundle打包工具.相信从事Unity开发或多或少都了解过AssetBundle,但简单的接口以及众多的细碎问题 ...