代码:

% Analog Signal
Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signal
Ts = 0.0002; n = -25:1:25; x = exp(-1000*abs(n*Ts)); % Discrete-time Fourier Transform
%Wmax = 2*pi*2000;
K = 500; k = 0:1:K; w = pi*k/K; % index array k for frequencies
X = x * exp(-j*n'*w); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
%% --------------------------------------------------------------------
%% START X's mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Example3.19a X its mag ang real imag');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; %axis([0,1,0,1.5]);
title('Magnitude Response');
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('Phase Response');
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
%% ------------------------------------------------------------------- X = real(X); w = [-fliplr(w), w(2:K+1)]; % Omega from -Wmax to Wmax
X = [fliplr(X), X(2:K+1)]; % X over -Wmax to Wmax interval
%% --------------------------------------------------------------------
%%
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', '<<DSP MATLAB>> Example3.19a');
set(gcf,'Color','white');
subplot(2,1,1); plot(t*1000,xa); grid on; %axis([0,1,0,1.5]);
title('Discrete Signal');
xlabel('t in msec units.'); ylabel('x1(n)'); hold on;
stem(n*Ts*1000,x); gtext('Ts=0.2 msec'); hold off; subplot(2,1,2); plot(w/pi, X); grid on; % axis([-1,1,-1,1]);
title('Discrete-time Fourier Transform');
xlabel('frequency in \pi units'); ylabel('X1(w)'); %% -------------------------------------------------------------------
%%
%% -------------------------------------------------------------------

  运行结果:

b

代码:

% Analog Signal
Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signal
%Ts = 0.0002; n = -25:1:25; x = exp(-1000*abs(n*Ts));
Ts = 0.001; n = -5:1:5; x = exp(-1000*abs(n*Ts)); % Discrete-time Fourier Transform
%Wmax = 2*pi*2000;
K = 500; k = 0:1:K; w = pi*k/K; % index array k for frequencies
X = x * exp(-j*n'*w); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
%% --------------------------------------------------------------------
%% START X's mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Example3.19b X its mag ang real imag');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magX); grid on; %axis([0,1,0,1.5]);
title('Magnitude Response');
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('Phase Response');
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
%% ------------------------------------------------------------------- X = real(X); w = [-fliplr(w), w(2:K+1)]; % Omega from -Wmax to Wmax
X = [fliplr(X), X(2:K+1)]; % X over -Wmax to Wmax interval
%% --------------------------------------------------------------------
%%
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', '<<DSP MATLAB>> Example3.19b');
set(gcf,'Color','white');
subplot(2,1,1); plot(t*1000,xa); grid on; %axis([0,1,0,1.5]);
title('Discrete Signal');
xlabel('t in msec units.'); ylabel('x1(n)'); hold on;
stem(n*Ts*1000,x); gtext('Ts=0.1 msec'); hold off; subplot(2,1,2); plot(w/pi, X); grid on; % axis([-1,1,-1,1]);
title('Discrete-time Fourier Transform');
xlabel('frequency in \pi units'); ylabel('X1(w)'); %% -------------------------------------------------------------------
%%
%% -------------------------------------------------------------------

  运行结果:

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

  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.18

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

  3. 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 ...

  4. 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, ...

  5. 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 ...

  6. DSP using MATLAB 示例Example3.17

  7. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  8. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

  9. DSP using MATLAB 示例 Example3.12

    用到的性质 代码: n = -5:10; x = sin(pi*n/2); k = -100:100; w = (pi/100)*k; % freqency between -pi and +pi , ...

随机推荐

  1. C Primer Plus_第三章_数据和C_复习题与编程练习

    Review long代替int类型变量的原因是什么? 在您的系统中,long可以容纳比int更大的数:如果您确实需要处理更大的值,那么使用一种在所有系统上都保证至少是32位的类型会使程序的可移植性更 ...

  2. code vs1262 不要把球传我(组合数学) 2012年CCC加拿大高中生信息学奥赛

    1262 不要把球传我 2012年CCC加拿大高中生信息学奥赛  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解  查看运行结果     题目描述 De ...

  3. mybatis跨XML引用

    resultMap中association标签的select属性使用嵌套查询的时候需要引用其它xml文件的配置 此时可以用要引用xml的namespace.引用select的ID 如 <resu ...

  4. 【leetcode】Reverse Linked List II (middle)

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1-> ...

  5. window.parent与window.openner区别介绍

    今天总结一下js中几个对象的区别和用法: 首先来说说 parent.window与top.window的用法 "window.location.href"."locati ...

  6. pod install 慢

    最近使用CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动 原因在于当执行以上两个命令的时候会升级Co ...

  7. [Android Pro] Android下toolbox简介

    toolbox是Android 自带的提供shell命令的软件.有点类似于busybox,但功能上好像弱很多.其源码可以从Android source code 中system/core/toolbo ...

  8. in addition to 和 except for

    except for 除了...以外(与 except for 连用的整体词与 except for 所跟的词往往不是同类的,是指整体中除去 一个细节.) eg:Your composition is ...

  9. ppt动画制作bullets

    动画->效果选项->作为一个对象 这样之后,字总是在一段时间后就自己出来,而不是我们点一下再出来,解决方法是对同一段字重复设置,后面那个会默认是点一下,出一张,在把之前的动画删除即可.

  10. C++ 内联函数笔记

    要使用内联函数,必须采取下述措施之一: +在函数声明前加上关键字inline: +在函数定义前加上关键字inline. 通常的做法是省略原型,将整个定义(即函数头和所有函数代码)放在本应提供原型的地方 ...