DSP using MATLAB 示例 Example3.19
2024-10-15 16:36:05
代码:
% 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)'); %% -------------------------------------------------------------------
%%
%% -------------------------------------------------------------------
运行结果:
最新文章
- ABP理论学习之内嵌资源文件
- jQuery实现手机竖直手风琴效果
- scrollViewDidEndScrollingAnimation和scrollViewDidEndDecelerating的区别
- Android shell 下 busybox,clear,tcpdump、、众多命令的移植
- Runloop之个人理解
- 关于Redis中交互的过程
- 15个不起眼但非常强大的 Vim 命令
- MySql增加字段、删除字段、修改字段
- ThinkPadT440 Ubuntu14.04 RTL8192EE 链接无线网
- python list求交集
- HDOJ 1253 胜利大逃亡(bfs)
- 实例演示如何在spring4.2.2中集成hibernate5.0.2并创建sessionFactory
- [三]基础数据类型之Integer详解
- socketserver + ftp
- springboot(十二):springboot单元测试、打包部署
- P1896 [SCOI2005]互不侵犯 状压dp
- MySQL 的 DISTINCT 应用于2列时
- Codeforces822 C. Hacker, pack your bags!
- Unity3D学习笔记第一课
- 如何用Procmon.exe来监视SQLSERVER的logwrite大小
热门文章
- webclient 和httpclient 应用
- .Net SqlDbHelper
- Alcatraz安装在xcode7失败执行下面代码
- 营业额统计(bzoj1588)
- CSS3与页面布局学习总结——Box Model、边距折叠、内联与块标签、CSSReset
- 四、优化及调试--网站优化--Yahoo军规上
- centos vsftp 服务器配置
- C#学习笔记-----C#枚举中的位运算权限分配
- 设计模式学习之代理模式(Proxy,结构型模式)(11)
- 【131031】jsp学习实例 (2013-10-31 15:29:28)