代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.15 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ------------------------------------------------------------------------
% 1 x(n) = [1, -2, 3, 1,-2,3, 1, -2, 3, 1, -2, 3,1,-2,3,1,-2,3]
% N=18 N=2uv
% x(n) = x(n+v)
% ------------------------------------------------------------------------ nn1 = [0:17];
xx1 = [1, -2, 3, 1, -2, 3, 1, -2, 3, 1, -2, 3, 1, -2, 3, 1, -2, 3];
NN1 = length(xx1); % length is 18 %m = mod_1(nn1, NN1);
%x = [xx1 zeros(1, 0)]; % padding zeros
%n = [nn1 max(nn1)+1:max(nn1)+6];
x = xx1;
n = nn1; figure('NumberTitle', 'off', 'Name', 'P5.15.1 x(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(nn1, xx1);
xlabel('n'); ylabel('x(n)');
title('x(n) ori sequence'); grid on;
subplot(2,1,2); stem(n, x);
xlabel('n'); ylabel('x(n)');
title('x(n) padding 0 zeros'); grid on; %% =============================================================================
%% DTFT X(w) of xn sequence, w=[0:2pi],
%% =============================================================================
MM = 500;
[Xw_DTFT, w] = dtft1(x, n, MM); magXw_DTFT = abs(Xw_DTFT); angXw_DTFT = angle(Xw_DTFT)/pi;
realXw_DTFT = real(Xw_DTFT); imagXw_DTFT = imag(Xw_DTFT); %% --------------------------------------------------------------
%% START X_DTFT's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.15.1 X(w) DTFT of x(n)');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magXw_DTFT); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X\_DTFT|');
subplot(2,2,3); plot(w/pi, angXw_DTFT); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Rad \pi'); %axis([-200,200,0,2]); subplot('2,2,2'); plot(w/pi, realXw_DTFT); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagXw_DTFT); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% --------------------------------------------------------------
%% END X_DTFT's mag ang real imag
%% -------------------------------------------------------------- %% ------------------------------------------------------------------
%% DFT(k) of xn sequence, k=[0:N-1]
%% w=2pi*k/N k=Nw/(2pi)
%% ------------------------------------------------------------------
N1 = length(x);
k1 = [0 : N1-1];
%k2 = [-N : N-1];
%k3 = [-N/2 : N/2];
Xk_DFT = dft(x, N1); % DFT
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.15.1 DFT(k) of x(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk_DFT); hold on; plot(N1*w/(2*pi), magXw_DTFT,'r--'); hold off;
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFT magnitude of x(n), N=18'); grid on;
subplot(2,1,2); stem(k1, angXk_DFT); hold on; plot(N1*w/(2*pi), angXw_DTFT,'r--'); hold off;
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFT angle of x(n), N=18'); grid on;

  运行结果:

第2小题:

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

  1. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  2. 《DSP using MATLAB》Problem 6.15

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

  3. 《DSP using MATLAB》Problem 4.15

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

  4. 《DSP using MATLAB》Problem 2.15

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

  5. 《DSP using MATLAB》Problem 8.15

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

  6. 《DSP using MATLAB》Problem 5.38

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

  7. 《DSP using MATLAB》Problem 5.31

    第3小题: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Out ...

  8. 《DSP using MATLAB》Problem 5.22

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

  9. 《DSP using MATLAB》Problem 5.21

    证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. Uva LV 2995 Image Is Everything 模拟,坐标映射,视图映射 难度: 1

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  2. WPF技术实现控件截图

    1.http://www.cnblogs.com/TianFang/archive/2012/10/07/2714140.html 2.http://www.silverlightchina.net/ ...

  3. 【原创】QT 打印输出

    list类 qDebug 的两种用法 #include <QDebug> int main(int argc,char *argv[]) { QList<int> list; ...

  4. SignalR 开始聊天室之旅

    首先明确需求,我现在有很多个直播间,每个直播间内需要存在一个聊天室,每个聊天室内可以存在很多人聊天,当然,只有登陆系统的会员才能聊天,没有登陆的,干看着吧! 根据以上需求,可以做出三个简单的页面:登陆 ...

  5. 【转载】JVM系列一:JVM内存组成及分配

    java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时 ...

  6. 查看linux 内核版本信息

    uname -r2.6.32-696.el6.x86_64uname -ix86_64

  7. Mysql text类型的最大长度

    MySQL 3种text类型的最大长度如下: TEXT 65,535 bytes ~64kb MEDIUMTEXT 16,777,215 bytes ~16Mb LONGTEXT 4,294,967, ...

  8. turtle

    画一组同切圆 输入 import turtle turtle.color('red') turtle.circle(30) turtle.circle(60) turtle.circle(90) tu ...

  9. matlab运行中出现“Caught "std::exception" Exception message is: Message Catalog MATLAB:builtins was not loaded from the file."

    在我运行过程中,经常爆出这一不确定是什么的问题,经排查后发现,原来是fopen 文件后,没有及时fclose导致的.

  10. [Paper] LCS: An Efficient Data Eviction Strategy for Spark

    Abstract Classical strategies do not aware of recovery cost, which could cause system performance de ...