《DSP using MATLAB》Problem 5.4
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 5.4 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ------------------------------------------
% 1 x1(n)=5sin(0.1pi*n) n=[0:19], N=40
% ------------------------------------------
L = 20; n = [0:L-1]; N = 40; k1 = [0 : N-1]; % wave parameters
%k2 = [-(N-1):0];
xn_1 = [5*sin(0.1*pi*n), zeros(1, N-L)];
Xk_1 = dfs(xn_1, N); % DFS
magXk = abs( [ Xk_1(1 : N)] ); % DFS magnitude
angXk = angle( Xk_1 )/pi; % DFS angle xn_2 = [xn_1(1:20) -xn_1(1:20)];
Xk_2 = dfs(xn_2, N);
magXk_2 = abs( [Xk_2(1:N)]);
angXk_2 = angle( Xk_2)/pi; figure('NumberTitle', 'off', 'Name', 'P5.4 xn_1 and xn_2')
set(gcf,'Color','white');
subplot(2,1,1); stem([0:N-1], xn_1);
xlabel('n'); ylabel('x(n)');
title('xn1 sequence in Problem 5.3, N=40'); grid on;
subplot(2,1,2); stem([0:N-1], xn_2);
xlabel('n'); ylabel('x(n)');
title('xn2 sequence, N=40'); grid on; %% ------------------------------------------------------
%% DFS(k) of xn1 sequence
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.4 DFS(k) of xn_1')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFS magnitude of xn1, N=40'); grid on;
subplot(2,1,2); stem(k1, angXk); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn1, N=40'); grid on; %% ------------------------------------------------------
%% DFS(k) of xn2 sequence
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P5.4 DFS(k) of xn_2')
set(gcf,'Color','white');
subplot(2,1,1); stem(k1, magXk_2); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('magnitude(k)');
title('DFS magnitude of xn2, N=40'); grid on;
subplot(2,1,2); stem(k1, angXk_2); %axis([-N/2, N/2, -0.5, 50.5]);
xlabel('k'); ylabel('angle(k)');
title('DFS angle of xn2, N=40'); grid on;
运行结果:
上面是从0到N-1范围内的图形。还可以得到[-N/2,N/2]范围内的。
《DSP using MATLAB》Problem 5.4的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.26
注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.25
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 7.16
使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.15
用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.13
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 7.12
阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
随机推荐
- VS2010安装项目程序打包操作详解
(转自:http://blog.sina.com.cn/s/blog_74f702e60101at62.html) 1.打开VS2010,选择 新建项目---其他项目类型---Visual Studi ...
- Resharper插件安装和破解
1.首先在最下面的地址,下载Resharper安装包,进行解压安装,安装界面如下: a 2.安装后 解压下载好的 文件 会得到如下: 3.打开序列号 会看到如下所示: 4.然后 复制 %LocalA ...
- Java压缩文件
压缩文件 package com.iss.cpf.windmanger.userprivilegeexport.bizlogic; import java.io.BufferedInputStream ...
- Java Swing 简单介绍
Swing 是一个为Java设计的GUI工具包. Swing是JAVA基础类的一部分. Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表. Swing提供许多比AWT更好的屏幕 ...
- oracle数据导入导出数据与编码格式不正确
1.导入dmp文件 imp ZHCG/ZHCG@ORCL file=E:\20160902.1007.dmp full=y 2.导出数据 exp system/manager@ORCL file ...
- Instruments leak黑魔法定位内存泄漏
leak是一款很赞的内存检查的工具,但在使用的过程中有点繁琐,至少有些底层的泄漏笔者还是不知道如何下手 下面介绍一下简单leak的使用: 首先你要确认你的target不会被拒绝,确保profile是d ...
- 深入理解java虚拟机---对象的结构(九)
注意: 我们可以看到的就是InstanceData的数据. 先转载一篇文章作为开头,因为讲的非常详细,我就简单加工下放到这里: 对象结构 在HotSpot虚拟机中,对象在内存中存储的布局可以分为3块区 ...
- 2.16 C++类与new和delete操作符
参考: http://www.weixueyuan.net/view/6347.html 总结: 当我们需要为类对象动态分配存储空间时,我们应该使用C++语言提供的new与new[]操作符,而不要使用 ...
- hdu5335(bfs,贪心)
In an n∗mn∗m maze, the right-bottom corner is the exit (position (n,m)(n,m) is the exit). In every p ...
- 适用于WIFI Hacking的无线网卡推荐
相信很多初次使用Kali Linux来进行无线渗透的小伙伴都曾遇到过一个非常头疼的问题,就是不知道如何选购一款合适的无线网卡.因为Kali Linux并不是所有的网卡都支持,一旦选错了网卡不仅会给我们 ...