用到的性质

代码:

n = -5:10; x = sin(pi*n/2);
k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , [0,pi] axis divided into 101 points.
X = x * (exp(-j*pi/100)) .^ (n'*k); % DTFT of x % signal decomposition
[xe,xo,m] = evenodd(x,n); % even and odd parts
XE = xe * (exp(-j*pi/100)) .^ (m'*k); % DTFT of xe
XO = xo * (exp(-j*pi/100)) .^ (m'*k); % DTFT of xo magXE = abs(XE); angXE = angle(XE); realXE = real(XE); imagXE = imag(XE);
magXO = abs(XO); angXO = angle(XO); realXO = real(XO); imagXO = imag(XO);
magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); %verification
XR = real(X); % real part of X
error1 = max(abs(XE-XR)); % Difference
XI = imag(X); % imag part of X
error2 = max(abs(XO-j*XI)); % Difference figure('NumberTitle', 'off', 'Name', 'x sequence')
set(gcf,'Color','white');
stem(n,x); title('x sequence'); xlabel('n'); ylabel('x(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'xe & xo sequence')
set(gcf,'Color','white');
subplot(2,1,1); stem(m,xe); title('xe sequence '); xlabel('m'); ylabel('xe(m)'); grid on;
subplot(2,1,2); stem(m,xo); title('xo sequence '); xlabel('m'); ylabel('xo(m)'); grid on; %% --------------------------------------------------------------------
%% START X's mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'X its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; axis([-1,1,0,9]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w/pi, angX/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realX); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagX); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% --------------------------------------------------------------
%% START XE's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'XE its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magXE); grid on; axis([-1,1,0,2]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |XE|');
subplot(2,2,3); plot(w/pi, angXE/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realXE); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagXE); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END XE's mag ang real imag
%% -------------------------------------------------------------- %% --------------------------------------------------------------
%% START XO's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'XO its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magXO); grid on; axis([-1,1,0,8]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |XO|');
subplot(2,2,3); plot(w/pi, angXO/pi); grid on; axis([-1,1,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realXO); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagXO); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END XO's mag ang real imag
%% -------------------------------------------------------------- %% ----------------------------------------------------------------
%% START Graphical verification
%% ----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Graphical verification');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,XR); grid on; axis([-1,1,-2,2]);
xlabel('frequency in \pi units'); ylabel('Re(X)'); title('Real Part of X ');
subplot(2,2,2); plot(w/pi,XI); grid on; axis([-1,1,-10,10]);
xlabel('frequency in \pi units'); ylabel('Im(X)'); title('Imaginary Part of X '); subplot(2,2,3); plot(w/pi,realXE); grid on; axis([-1,1,-2,2]);
xlabel('frequency in \pi units'); ylabel('XE'); title('Transform of even part ');
subplot(2,2,4); plot(w/pi,imagXO); grid on; axis([-1,1,-10,10]);
xlabel('frequency in \pi units'); ylabel('XO'); title('Transform of odd part'); %% ----------------------------------------------------------------
%% END Graphical verification
%% ----------------------------------------------------------------

  运行结果:

DSP using MATLAB 示例 Example3.12的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  6. DSP using MATLAB 示例 Example3.11

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)); k = -100:100; w = (pi/100)*k; % freqency between -pi an ...

  7. DSP using MATLAB 示例 Example3.10

    用到的性质 上代码: n = -5:10; x = rand(1,length(n)) + j * rand(1,length(n)); k = -100:100; w = (pi/100)*k; % ...

  8. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  9. DSP using MATLAB 示例Example3.17

随机推荐

  1. LeetCode 263 Ugly Number

    Problem: Write a program to check whether a given number is an ugly number. Ugly numbers are positiv ...

  2. java获得本机IP,名称等

    import java.net.InetAddress; import java.net.UnknownHostException; public class GetLocalIP { public ...

  3. Mysql 调用存储过程的两种方式

    一,使用call语句: 如:创建 call 调用: 使用占位符,通过prepare,execute调用:

  4. NYOJ之XX和OO

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAskAAAI0CAIAAABgWyN9AAAgAElEQVR4nO3dPW7jyt4n4NmEcy/EaW

  5. Lattice Diamond 的学习之新建工程

    1).打开软件 在软件打开后的初始布局会有一个Start  page 可以创建.打开.导入一个ISPLEVER 工程. 2).建立工程:1,Start page 中Project --> NEW ...

  6. LR结果分析——TPS和吞吐率

    针对吞吐率和TPS的关系,这个在结果分析中如何使用,就个人经验和朋友讨论后,提出如下建议指导,欢迎同僚指正. TPS:transaction per second 服务器每秒处理的事务数. 吞吐率:测 ...

  7. Android Matrix

    转自 :http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#code Matrix的数学原理 平移变换 旋转变换 缩放变换 错切 ...

  8. c#将http调用返回额json中的有关中文的unicode转换为中文(转)

    转转地址:http://www.cnblogs.com/promise-7/archive/2012/11/05/2755515.html 中文转Unicode:HttpUtility.UrlEnco ...

  9. zTree控件的使用

    最常用的使用方式是json格式 .net递归实现对象生成json格式字符串 代码: using System; using System.Collections.Generic; using Syst ...

  10. Delphi的字符串、PChar和字符数组之间的转换

    参考:http://my.oschina.net/kavensu/blog/193719 以下的各种方法都是我在Delphi 6的环境下测试成功的,可能根据你的开发环境.不同的上下文语境……有一些可能 ...