《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,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
随机推荐
- laravel上传文件FTP驱动配置
FTP驱动配置 Laravel 的文件系统集成了 FTP 操作,不过,框架默认的配置文件 filesystems.php 并没有提供示例配置.如果你需要配置一个FTP文件系统,可以使用以下示例配置: ...
- eclipse.ini参数配置
-vmD:/jdk1.6/Java/jdk1.6.0_45/bin/javaw.exe-vmargs-Xms1024m-Xmx1024m-XX:MaxPermSize=1024m-XX:Reserve ...
- 利用awk处理学生成绩问题(难度较大)
学生成绩表单如下: Name,Team,First Test, Second Test, Third Test Tom,Red,,, Joe,Green,,, Maria,Blue,,, Fred,B ...
- 【转载】 unity 塔防游戏
原文地址: Part1的地址:http://www.cnblogs.com/lcxBlog/p/6075984.html Part2的地址:http://www.cnblogs.com/lcxBlog ...
- 【资料收集】QT学习资料
几个专栏 Qt学习之路(3):Hello, world!(续) - 豆子空间 - 51CTO技术博客 http://devbean.blog.51cto.com/448512/194137 Qt 学习 ...
- redis、memcache、mongoDB 对比
从以下几个维度,对 redis.memcache.mongoDB 做了对比. 1.性能 都比较高,性能对我们来说应该都不是瓶颈. 总体来讲,TPS 方面 redis 和 memcache 差不多,要大 ...
- mysql存储过程中使用游标
用户变量一般以@开头,作用于全局范围 局部变量需用 declare 定义格式为 declare 变量名 数据类型 [default value]; mysql 数据类型有 int ,float,dat ...
- 【Ctrl】 + 【Alt】 + 【F1~F6】 和 【Ctrl】 + 【Alt】 + 【T】打开的终端有什么不同?
ctrl +alt +Fn 打开的是模拟终端,简单说来,Linux系统一开机会自动打开6个模拟终端,然后自动切换到其中一个(一般来说是切换到图形界面的那个也就是说窗口管理器是在这6个模拟终端中运行的) ...
- linux 删除日志
https://jingyan.baidu.com/album/c1a3101e73129ade656deb9d.html?picindex=2 里面的 ls -s 可以看到目录 https://zh ...
- 补偿接口中循环一直执行sql的问题
事件: 项目即将上线,测试,观察日志,发现一sql在dal.xml中一直刷日志,但对应在biz日志却是空的 排查步骤: 1.查看对应日志的sql,在项目中找到对应代码所在位置,查看入口与代码逻辑 接口 ...