DSP using MATLAB 示例Example3.8
代码:
x = rand(1,11); n = 0:10;
k = 0:500; w = (pi/500)*k; % [0,pi] axis divided into 501 points.
X = x * (exp(-j*pi/500)) .^ (n'*k); % DTFT of x % signal shifted by two samples
y = x; m = n + 2;
Y = y * (exp(-j*pi/500)) .^ (m'*k); % DTFT of y = x(n-2) magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X);
magY = abs(Y); angY = angle(Y); realY = real(Y); imagY = imag(Y); %verification
Y_check = (exp(-j*2) .^ w) .* X; % multiplication by exp(-j2w)
error = max(abs(Y-Y_check)); % Difference figure('NumberTitle', 'off', 'Name', 'x & y sequence')
set(gcf,'Color','white');
subplot(2,1,1); stem(n,x); title('x sequence'); xlabel('n'); ylabel('x(n)'); grid on;
subplot(2,1,2); stem(m,y); title('y sequence'); xlabel('n'); ylabel('y(n)'); 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([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |X|');
subplot(2,2,3); plot(w/pi, angX/pi); grid on; % axis([-2,2,-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 Y's mag ang real imag
%% --------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Y its Magnitude and Angle, Real and Imaginary Part');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magY); grid on; % axis([-2,2,0,15]);
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude |Y|');
subplot(2,2,3); plot(w/pi, angY/pi); grid on; % axis([-2,2,-1,1]);
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realY); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagY); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary'); %% --------------------------------------------------------------
%% END Y's mag ang real imag
%% --------------------------------------------------------------
运行结果:
DSP using MATLAB 示例Example3.8的更多相关文章
- 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 ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- 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 ...
- 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, ...
- 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 ...
- DSP using MATLAB 示例Example3.17
- 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 ...
- 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 ...
- 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 , ...
随机推荐
- 用原生DOM 遍历页面节点
代码丢失,直接上图:
- HTML 基础
1.HTML 超文本标记语言 2.网页分类: 动态网页 静态网页 ①静态网页与动态网页区别: 主要:动态网页与数据库链接,静态网页不与数据库连接: ②静态网页 修改展示图片 必须修改源代码 : ...
- 【Git】笔记5 分支管理2
来源:廖雪峰 通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息. 如果要强制禁用Fast forward模式,Git就会在merge时生成一 ...
- 在cmd窗口中运行php命令
1.首先安装php.我使用的是wamp,里面包含php5.5.12 2.将C:\wamp\bin\php\php5.5.12添加到环境变量Path中 3.在cmd中运行php -v可以查看php版本相 ...
- 用 MyEclipse 开发 Spring 入门操作
何为Spring Spring框架是一个轻量级的控制反转(IOC)技术和面向切面编程(AOP)技术的容器框架,利用Spring框架可以实现对象的生命周期管理和分离应用系统中的业务逻辑组件和通用的技术服 ...
- 【Mongodb】3.X 配置身份验证
配置身份验证详解: 开启认证: 启动MongoDB./mongodb --syslog --fork --port 20000 --auth 1.如果不添加参数:auth,表明用默认的root的权限 ...
- Android 添加cookie
/** * 添加cookie * * @param url */ private void setCookie(String url) { // 获取uid String uid = UserData ...
- Clr Via C#读书笔记---I/O限制的异步操作
widows如何执行I/O操作 构造调用一个FileStream对象打开一个磁盘文件-----FileStream.Read方法从文件中读取数据(此时线程从托管代码转为本地/用户模式代码)- ...
- JavaWeb学习之Path总结、ServletContext、ServletResponse、ServletRequest(3)
1.Path总结 1.java项目 1 File file = new File(""); file.getAbsolutePath(); * 使用java命令,输出路径是,当前j ...
- C# 使用Conditional特性而不是#if条件编译
概述 #if/#endif 语句常用来基于同一份源码生成不同的编译结果,其中最常见的就是debug版和release版.但是这些工具在实际应用中并不是非常友好,因为它们容易被滥用,其代码页进而难以理解 ...