1、代码

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.17 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------------
% X(k) is 10-point DFTs of real-valued sequence x(n)
% X(k) = [10, -2+3j, 3+4j, 2-3j, 4+5j, 12, 4-5j, 2+3j, 3-4j, -2-3j]
% N = 10 k=[0:9]
% 1 y(n) = x((2-n))10
% ------------------------------------------------------------------------------------- k1 = [0:9];
Xk_DFT = [10, -2+3j, 3+4j, 2-3j, 4+5j, 12, 4-5j, 2+3j, 3-4j, -2-3j];
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.17.1 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=10'); 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=10'); grid on;
subplot(2,2,2); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n), N=10'); 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=10'); grid on; [xn] = real(idft(Xk_DFT, N1)); % real-valued sequence
n = [0 : N1-1]; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 1st way to get y(n)-----circular shifft
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
xn_cirfold = xn(mod(-n,N1)+1);
m = 2; % shift
yn1 = cirshftt(xn_cirfold, m, length(xn)); Xfk_DFT = dft(xn_cirfold, N1);
magXfk_DFT = abs( [ Xfk_DFT ] ); % DFT magnitude
angXfk_DFT = angle( [Xfk_DFT] )/pi; % DFT angle
realXfk_DFT = real(Xfk_DFT); imagXfk_DFT = imag(Xfk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.17.1 X((-k)), DFT of x((-n))')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magXfk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of x((-n)), N=10'); grid on;
subplot(2,2,3); stem(k1, angXfk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of x((-n)), N=10'); grid on;
subplot(2,2,2); stem(k1, realXfk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x((-n)), N=10'); grid on;
subplot(2,2,4); stem(k1, imagXfk_DFT);
axis([0, 10, -5, 5.05]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of x((-n)), N=10'); grid on; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 2ed way to get y(n)-----IDFT of Y(k)
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
k1 = [0:9];
Yk_DFT = exp(-j*2*pi*(2*k1)/10) .* Xk_DFT(mod(-k1, N1)+1);
N1 = length(Yk_DFT); % length is 10 magYk_DFT = abs( [ Yk_DFT ] ); % DFT magnitude
angYk_DFT = angle( [Yk_DFT] )/pi; % DFT angle
realYk_DFT = real(Yk_DFT); imagYk_DFT = imag(Yk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.17.1 DFT(k) of y(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magYk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of y(n), N=10'); grid on;
subplot(2,2,3); stem(k1, angYk_DFT);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of y(n), N=10'); grid on;
subplot(2,2,2); stem(k1, realYk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of y(n), N=10'); grid on;
subplot(2,2,4); stem(k1, imagYk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of y(n), N=10'); grid on; [yn2] = real(idft(Yk_DFT, N1));
n = [0 : N1-1]; figure('NumberTitle', 'off', 'Name', 'P5.17.1 x(n) & y(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(n, xn);
xlabel('n'); ylabel('x(n)');
title('x(n), IDFT of X(k)'); grid on;
subplot(2,2,2); stem(n, yn1);
xlabel('n'); ylabel('y(n)');
title('y(n) by circular shift x((2-n))_N N=10'); grid on;
subplot(2,2,3); stem(n, xn_cirfold);
xlabel('n'); ylabel('x((-n))');
title('x((-n)) N=10'); grid on;
subplot(2,2,4); stem(n, yn2);
xlabel('n'); ylabel('y(n)');
title('y(n) by IDFT of Y(k)'); grid on;

  运行结果:

4、代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.17 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % -------------------------------------------------------------------------------------
% X(k) is 10-point DFTs of real-valued sequence x(n)
% X(k) = [10, -2+3j, 3+4j, 2-3j, 4+5j, 12, 4-5j, 2+3j, 3-4j, -2-3j]
% N = 10 k=[0:9]
% 4 y(n) = x(n) Circular-Conv x((-n))10
% ------------------------------------------------------------------------------------- k1 = [0:9];
Xk_DFT = [10, -2+3j, 3+4j, 2-3j, 4+5j, 12, 4-5j, 2+3j, 3-4j, -2-3j];
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.17.4 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=10'); 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=10'); grid on;
subplot(2,2,2); stem(k1, realXk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of x(n), N=10'); 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=10'); grid on; [xn] = real(idft(Xk_DFT, N1)); % real-valued sequence
n = [0 : N1-1]; % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 1st way to get y(n)-----circular
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
xn_cirfold = xn(mod(-n,N1)+1);
yn1 = circonvt(xn, xn_cirfold, N1); % +++++++++++++++++++++++++++++++++++++++++++++++++++++++
% 2ed way to get y(n)-----IDFT of Y(k)
% +++++++++++++++++++++++++++++++++++++++++++++++++++++++
k1 = [0:9];
Xfk_DFT = dft(xn_cirfold, N1); Yk_DFT = Xk_DFT .* Xfk_DFT;
N1 = length(Yk_DFT); % length is 10 magYk_DFT = abs( [ Yk_DFT ] ); % DFT magnitude
angYk_DFT = angle( [Yk_DFT] )/pi; % DFT angle
realYk_DFT = real(Yk_DFT); imagYk_DFT = imag(Yk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.17.4 DFT(k) of y(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(k1, magYk_DFT);
xlabel('k'); ylabel('magnitude(k)');
title('magnitude DFT of y(n), N=10'); grid on;
subplot(2,2,3); stem(k1, angYk_DFT);
xlabel('k'); ylabel('angle(k)');
title('angle DFT of y(n), N=10'); grid on;
subplot(2,2,2); stem(k1, realYk_DFT);
xlabel('k'); ylabel('real (k)');
title('real DFT of y(n), N=10'); grid on;
subplot(2,2,4); stem(k1, imagYk_DFT);
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('imag (k)');
title('imag DFT of y(n), N=10'); grid on; [yn2] = real(idft(Yk_DFT, N1));
n = [0 : N1-1]; figure('NumberTitle', 'off', 'Name', 'P5.17.4 x(n) & y(n)')
set(gcf,'Color','white');
subplot(2,2,1); stem(n, xn);
xlabel('n'); ylabel('x(n)');
title('x(n), IDFT of X(k)'); grid on;
subplot(2,2,2); stem(n, yn1);
xlabel('n'); ylabel('y(n)');
title('y(n) by x(n) Circular-Conv x((-n))_N N=10'); grid on;
%subplot(2,2,3); stem(n, xn_cirfold);
%xlabel('n'); ylabel('x((-n))');
%title('x((-n)) N=10'); grid on;
subplot(2,2,4); stem(n, yn2);
xlabel('n'); ylabel('y(n)');
title('y(n) by IDFT of Y(k)'); grid on;

  运行结果:

《DSP using MATLAB》Problem 5.17的更多相关文章

  1. 《DSP using MATLAB》Problem 6.17

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

  2. 《DSP using MATLAB》Problem 3.17

    用差分方程两边进行z变换,再变量带换得到频率响应函数(或转移函数,即LTI系统脉冲响应的DTFT). 代码: %% ------------------------------------------ ...

  3. 《DSP using MATLAB》Problem 2.17

    1.代码: %% ------------------------------------------------------------------------ %% Output Info abo ...

  4. 《DSP using MATLAB》Problem 8.17

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

  5. 《DSP using MATLAB》Problem 4.17

  6. 《DSP using MATLAB》Problem 5.22

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...

  7. 《DSP using MATLAB》Problem 5.15

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

  8. 《DSP using MATLAB》Problem 2.18

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

  9. 《DSP using MATLAB》Problem 7.28

    又是一年五一节,朋友圈都是晒名山大川的,晒脑袋的,我这没钱的待在家里上网转转吧 频率采样法设计带通滤波器,过渡带中有一个样点 代码: %% ++++++++++++++++++++++++++++++ ...

随机推荐

  1. am335x system upgrade uboot ethernet(二)

    系统可以通过SD卡引道之后,为了之后了调试方便 通过查看网卡的硬件设计 正常来说需要注意的有如下几点: 1) 网口 的接线方式: RMII 2) 网口的PHY地址两张网口,这里我们只需先初始化一张网卡 ...

  2. String常用方法

    1. String StringBuffer StringBuilder的区别: 001.在执行速度方法 StringBuilder > StringBuffer > String 002 ...

  3. 使用DDMS查看设备内的文件系统

    system文件系统存储了一些系统相关的文件 system/app里面是系统自带的应用程序 system/fonts里面存放的是系统自带的字体 system/frameworks里面存放的是系统的一些 ...

  4. Git的基本使用(github)

    关于Git的基本使用: 上传本地文件到github仓库中 首先要有自己的github账号,新建仓库: saiku-3.9 其次 本地安装好 git , 在本地任意目录下新建目录 saiku-3.9, ...

  5. 【转】caffe数据层及参数

    原文: 要运行caffe,需要先创建一个模型(model),如比较常用的Lenet,Alex等, 而一个模型由多个层(layer)构成,每一层又由许多参数组成.所有的参数都定义在caffe.proto ...

  6. jq demo—图片翻页展示效果 animate()动画

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  7. 什么是XP

    极限编程(XP)是敏捷过程中最富盛名的一个.下述这些特点使得敏捷过程能够较好地适应商业竞争环境下对小型项目提出的有效资源和有限开发时间的约束. 极限编程的有效实践 极限编程的整体开发过程 极限编程的迭 ...

  8. Java作业五

    1.编程生成10个1~100之间的随机数,并统计每个数出现的概率. 这个博文里面又random的详细解释:https://www.cnblogs.com/ningvsban/p/3590722.htm ...

  9. Oracle学习(四)_SQL函数

    --第一部分:SQL基础 --ch1 简单查询 --ch2 查询基本概念 --ch3 数据过滤 --第二部分:多表操作 --ch4 集合理论 --ch5 内连接 --ch6 外连接 --ch7 子查询 ...

  10. <YaRN><Official doc><RM REST API's>

    Overview ... YARN Architecture The fundamental idea of YARN is to split up the functionalities of re ...