代码:

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

    --联合结果集union(集合运算符-- group by StudentNo union ---union可以合并多个结果集 --它有两个前提和一个注意: --1.合并的结果集的列数必须完全一致 - ...

  2. va_list使用

    http://www.programfan.com/blog/article.asp?id=41937

  3. September 16th 2016 Week 38th Friday

    All the treasures of the earth would not bring back one lost moment. 机会失去不再来,千贯万贯难赎回. Cherish your h ...

  4. Redis自定义动态字符串(sds)模块(一)

    Redis开发者在开发过程中没有使用系统的原始字符串,而是使用了自定义的sds字符串,这个模块的编写是在文件:sds.h和sds.c文件中.Redis自定义的这个字符串好像也不是很复杂,远不像ngin ...

  5. mvn命令备忘

    转换成eclipse项目mvn eclipse:eclipse 跳过testmvn install -Dmaven.test.skip=true mvn clean install -DskipTes ...

  6. XPath的基本使用

    XPath XPath 使用路径表达式来选取 XML 文档中的节点或节点集. 路径表达式 结果 bookstore 选取 bookstore 元素的所有子节点. /bookstore 选取根元素 bo ...

  7. Swift - 初始化Initialization

    Ps:苹果官方文档-Initialization 自定义控件初始化中常见的几种错误(指定构造器和便利构造器)截图:   意思是:1.没有添加重写符override(重写父类方法)2.没有重写initW ...

  8. linux 普通用户切换成root免密码

    [root@ok ~]# vim /etc/pam.d/su 下面是/etc/pam.d/su文件的内容 #%PAM-1.0 auth sufficient pam_rootok.so # Uncom ...

  9. Recovery和Charger模式下屏幕旋转180度

    转自:http://www.etwiki.cn/android/1267.html 如何让Recovery (系统固件升级),charger(关机充电动画)时屏幕旋转180度 解决方法: 1.在boo ...

  10. 那些年,我们在Django web开发中踩过的坑(一)——神奇的‘/’与ajax+iframe上传

    一.上传图片并在前端展示 为了避免前端整体刷新,我们采用ajax+iframe(兼容所有浏览器)上传,这样用户上传之后就可以立即看到图片: 上传前: 上传后: 前端部分html: <form s ...