代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% 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的更多相关文章

  1. 《DSP using MATLAB》Problem 6.18

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 4.18

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 3.18

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.18

    1.代码: function [y, H] = conv_tp(h, x) % Linear Convolution using Toeplitz Matrix % ----------------- ...

  5. 《DSP using MATLAB》Problem 8.18

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  6. 《DSP using MATLAB》Problem 5.15

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  7. 《DSP using MATLAB》Problem 4.15

    只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...

  8. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. word个人信息的一种处理方式

    下面是一种解决office文件更改作者的方法,步骤如下: 第一步:进入Word,Excel,或PowerPoint, 随便打开一个文件: 第二步:点击左上角的文件,进入文件功能界面: 第三步:点击选项 ...

  2. CString、string、const char*的相互转换

    环境:vs2010 1.CString转string //第一种方式: CString str = _T("CSDN"); USES_CONVERSION; std::string ...

  3. fastIO

    文件系统除了处理正常的IRP 之外,还要处理所谓的FastIo.FastIo是Cache Manager 调用所引发的一种没有irp 的请求.换句话说,除了正常的Dispatch Functions ...

  4. .NET界面控件DevExpress发布v18.2.4|附下载

    DevExpress Universal Subscription(又名DevExpress宇宙版或DXperience Universal Suite)是全球使用广泛的.NET用户界面控件套包,De ...

  5. shell脚本实例-内存磁盘使用警告

    1,磁盘使用警告并发送邮件 #!usr/bin/bash #df -Th|grep '/$' 这个是获取内存使用的那一条记录 #后面两句是获取内存的使用率 disk=`df -Th|grep '/$' ...

  6. lvs的FULLNAT

  7. GIL 相关 和进程池

    #GIL (global interpreter Lock) #全局解释器锁 :锁是为了避免资源竞争造成数据错乱 #当一个py启动后 会先执行主线程中的代码#在以上代码中有启动了子线程 子线程的任务还 ...

  8. python-web-django前后端交互

    1.前端请求数据URL由谁来写 在开发中,URL主要是由后台来写好给前端. 若后台在查询数据,需要借助查询条件才能查询到前端需要的数据时,这时后台会要求前端提供相关的查询参数(即URL请求的参数). ...

  9. python中的pandas的两种基本使用

    python中的pandas的两种基本使用2018年05月19日 16:03:36 木子柒努力成长 阅读数:480 一.pandas简介 pandas:panel data analysis(面板数据 ...

  10. getHibernateTemplate().save(t)执行不成功,数据不能插入到数据库

    BaseDaoImpl类中的代码如下 public void save(T t) {System.out.println(666);getHibernateTemplate().save(t);    ...