《DSP using MATLAB》示例Example5.2

代码:
L = 5; N = 20; k = [-N/2:N/2]; % square wave parameters
xn = [ones(1,L), zeros(1,N-L)]; % Sq wave x(n)
Xk = dfs(xn,N); % DFS %% ----------------------------------------------------
%% START periodic sequence
%% ----------------------------------------------------
self_periods = N;
periods = 3;
n1 = [-20: -1 + (periods-1) * self_periods]; xtilde = xn' * ones(1,periods); xtilde = (xtilde(:))'; figure('NumberTitle', 'off', 'Name', 'Example5.2 3 Period Sequence')
set(gcf,'Color','white');
stem(n1,xtilde); title('Three Peroids of xtilde(n)');axis([-20, 40, -0.5, 1.5]);
xlabel('n'); ylabel('xtilde(n)');grid on;
%% ----------------------------------------------------
%% END periodic sequence
%% ---------------------------------------------------- magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]); % DFS magnitude figure('NumberTitle', 'off', 'Name', 'Example5.2')
set(gcf,'Color','white');
subplot(2,2,1); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
xlabel('k'); ylabel('Xtilde(k)'); grid on;
title('DFS of SQ. wave: L=5 N=20'); L = 5; N = 40; k = [-N/2:N/2]; % square wave parameters
xn = [ones(1,L), zeros(1,N-L)]; % Sq wave x(n)
Xk = dfs(xn,N); % DFS magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]); % DFS magnitude %figure('NumberTitle', 'off', 'Name', 'Example5.2')
%set(gcf,'Color','white');
subplot(2,2,2); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
xlabel('k'); ylabel('Xtilde(k)'); grid on;
title('DFS of SQ. wave: L=5 N=40'); L = 5; N = 60; k = [-N/2:N/2]; % square wave parameters
xn = [ones(1,L), zeros(1,N-L)]; % Sq wave x(n)
Xk = dfs(xn,N); % DFS magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]); % DFS magnitude %figure('NumberTitle', 'off', 'Name', 'Example5.2')
%set(gcf,'Color','white');
subplot(2,2,3); stem(k, magXk); axis([-N/2, N/2, -0.5, 5.5]);
xlabel('k'); ylabel('Xtilde(k)'); grid on;
title('DFS of SQ. wave: L=5 N=60'); L = 7; N = 60; k = [-N/2:N/2]; % square wave parameters
xn = [ones(1,L), zeros(1,N-L)]; % Sq wave x(n)
Xk = dfs(xn,N); % DFS magXk = abs([Xk(N/2+1:N) Xk(1:N/2+1)]); % DFS magnitude %figure('NumberTitle', 'off', 'Name', 'Example5.2')
%set(gcf,'Color','white');
subplot(2,2,4); stem(k, magXk); axis([-N/2, N/2, -0.5, 7.5]);
xlabel('k'); ylabel('Xtilde(k)'); grid on;
title('DFS of SQ. wave: L=7 N=60');
运行结果:


《DSP using MATLAB》示例Example5.2的更多相关文章
- 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.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.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.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 , ...
随机推荐
- codeforces 514B. Han Solo and Lazer Gun 解题报告
题目链接:http://codeforces.com/problemset/problem/514/B 题目意思:给出双头枪的位置(x0, y0),以及 n 个突击队成员的坐标.双头枪射击一次,可以把 ...
- maven加载本地lib下的jar包
1.本地lib下有jar 2.命令: mvn install:install-file -Dfile=juh-3.0.1.jar -DgroupId=org.openoffice -Dartifact ...
- js方法类库封装的简易示例
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></s ...
- sqlserver 导出数据字典
-- 数据字典 SELECT ( then d.name else '' end)表名, a.colorder 字段序号, a.name 字段名, ( then '√'else '' end) 标识, ...
- python基础——访问限制
python基础——访问限制 在Class内部,可以有属性和方法,而外部代码可以通过直接调用实例变量的方法来操作数据,这样,就隐藏了内部的复杂逻辑. 但是,从前面Student类的定义来看,外部代码还 ...
- 检查C++内存泄露
#ifdef _DEBUG #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) #else #define DEBUG_ ...
- Qt中如何添加.qrc文件
You need a resource file (.qrc) within which you embed the input text file. The input file can be an ...
- UVA 10405最长公共子序列
裸最长公共子序列,直接贴代码 #include<cstdio> #include<iostream> #include<algorithm> #include< ...
- MVC - 18.缓存
1.使用输出缓存 (不灵活,问题比较多,不建议使用) /// <summary> /// datagrid列表 /// </summary> /// <returns&g ...
- 基于SNMP的路由拓扑发现算法收集
一.三层(网络层)发现 算法来源:王娟娟.基于SNMP的网络拓扑发现算法研究.武汉科技大学硕士学位论文,2008 数据结构: 待检路由设备网关链表:存放指定深度内待检路由设备的网关信息,处理后删除. ...