代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% 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. Linux command automake

    Linux command automake [Purpose]        Learning linux command automake for generate Makefile.in for ...

  2. 使用X-UA-Compatible来设置IE8兼容模式

    使用X-UA-Compatible来设置IE8兼容模式 本文向大家描述一下如何使用X-UA-Compatible来设置IE8兼容模式,X-UA-Compatible是针对IE8兼容模式,X-UA-Co ...

  3. day24 模块03_re

    休养生息 --模块03 1.正则表达式 2.在python中使用正则.re 一,正则表达式 (匹配字符串,主要是给字符串使用的) 1)元字符 .  除换行符之外 \w 数字,字母,下划线组成   \W ...

  4. python中的__call__()函数

    __call__ 在Python中,函数其实是一个对象: >>> f = abs >>> f.__name__ 'abs' >>> f(-123) ...

  5. SQL-4查找所有已经分配部门的员工的last_name和first_name(自然连接)

    题目描述 查找所有已经分配部门的员工的last_name和first_nameCREATE TABLE `dept_emp` (`emp_no` int(11) NOT NULL,`dept_no` ...

  6. [PyImageSearch] Ubuntu16.04下针对OCR安装Tesseract

    今天的博文是安装和使用光学字符识别(OCR)的Tesseract库的两部分系列的第一部分. 本系列的第一部分将着重于在您的机器上安装和配置Tesseract,然后使用tesseract命令将OCR应用 ...

  7. Convert the AScii to SAC file

    readtable *.txt w sac  filename.sac ch delta dela0 w over

  8. ORACLE CASE WHEN 及 SELECT CASE WHEN的用法

    Case具有两种格式.简单Case函数和Case搜索函数. --简单Case函数 CASE sex WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE '其他' END ...

  9. Java 容器

    摘录来至https://www.cnblogs.com/LipeiNet/p/5888513.html https://www.cnblogs.com/acm-bingzi/p/javaMap.htm ...

  10. adb shell按键操作(input keyevent)

    前言:input keyeven操作发送手机上常用的一些按键操作 一.keyevent事件对应数字 电话键 KEYCODE_CALL: 拨号键 KEYCODE_ENDCALL: 挂机键 KEYCODE ...