代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.4 \n\n'); banner();
%% ------------------------------------------------------------------------ % ----------------------------------------------
% Rectangle Window sequence
% ----------------------------------------------
M = 101; n1_start = 0; n1_end = M;
n1 = [n1_start : n1_end - 1]; x1 = ones(1, length(n1)); figure('NumberTitle', 'off', 'Name', 'Problem 3.4 x1(n) Rectangle');
set(gcf,'Color','white');
stem(n1, x1);
xlabel('n'); ylabel('x1');
title(sprintf('x1(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X1] = dtft(x1, n1, w); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); figure('NumberTitle', 'off', 'Name', 'Problem 3.4 DTFT of Rm(n)');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX1/max(magX1)); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX1); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % --------------------------------------------------
% Hanning Window Sequence
% --------------------------------------------------
%n2_start = -9; n2_end = 15;
%n2 = [n2_start : n2_end];
n2 = n1;
x2 = 0.5 * (1 - cos(2*pi*n1/(M-1))) .* x1; figure('NumberTitle', 'off', 'Name', 'Problem 3.4 x2(n) Hanning');
set(gcf,'Color','white');
stem(n2, x2);
xlabel('n'); ylabel('x2');
title(sprintf('x2(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X2] = dtft(x2, n2, w); magX2 = abs(X2); angX2 = angle(X2); realX2 = real(X2); imagX2 = imag(X2); figure('NumberTitle', 'off', 'Name', 'Problem 3.4 DTFT of Cm(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX2/max(magX2)); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX2); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % --------------------------------------------------
% Triangular Window Sequence
% --------------------------------------------------
%n3_start = -3; n3_end = 10;
%n3 = [n3_start : n3_end];
n3 = n1;
x3 = (1 - abs(M-1-2*n3)/(M-1)) .* x1; figure('NumberTitle', 'off', 'Name', 'Problem 3.4 x3(n) Triangular');
set(gcf,'Color','white');
stem(n3, x3);
xlabel('n'); ylabel('x3');
title(sprintf('x3(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X3] = dtft(x3, n3, w); magX3 = abs(X3); angX3 = angle(X3); realX3= real(X3); imagX3 = imag(X3); figure('NumberTitle', 'off', 'Name', 'Problem 3.4 DTFT of Tm(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX3/max(magX3)); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX3); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians'); % ---------------------------------------------
% Hamming Window sequence
% ---------------------------------------------
%n4_start = 0; n4_end = 50;
%n4 = [n4_start : n4_end];
n4 = n1;
x4 = (0.54 - 0.46 * cos(2*pi*n4/(M-1))) .* x1; figure('NumberTitle', 'off', 'Name', 'Problem 3.4 x4(n) Hamming');
set(gcf,'Color','white');
stem(n4, x4, 'filled');
xlabel('n'); ylabel('x4');
title(sprintf('x4(n) sequence, M = %d', M)); grid on; MM = 500;
k = [-MM:MM]; % [-pi, pi]
%k = [0:M]; % [0, pi]
w = (pi/MM) * k; [X4] = dtft(x4, n4, w); magX4 = abs(X4); angX4 = angle(X4); realX4= real(X4); imagX4 = imag(X4); figure('NumberTitle', 'off', 'Name', 'Problem 3.4 DTFT of Hm(n)');;
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magX4/max(magX4)); grid on;
title('Magnitude Part');
xlabel('frequency in \pi units'); ylabel('Magnitude');
subplot(2,1,2); plot(w/pi, angX4); grid on;
title('Angle Part');
xlabel('frequency in \pi units'); ylabel('Radians');

  运行结果:

矩形窗:

汉宁窗:

三角窗:

汉明窗:

《DSP using MATLAB》Problem 3.4的更多相关文章

  1. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  2. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  6. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  7. 《DSP using MATLAB》Problem 7.15

    用Kaiser窗方法设计一个台阶状滤波器. 代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  8. 《DSP using MATLAB》Problem 7.14

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 7.13

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  10. 《DSP using MATLAB》Problem 7.12

    阻带衰减50dB,我们选Hamming窗 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. 基因家族收缩和扩张分析 & Selective loss pathway & 泛基因组

    套路 这通常就是基因组组装后的必做分析,通过比较基因组学的手段进行分析,可以知道所研究物种在进化过程中哪些核心基因家族发生了变化,从而导致了其特殊的适应性机制的形成. 参考: Extremotoler ...

  2. Rspec: feature spec 功能测试 测试JavaScript.

    我们要把应用各组件放在一起做集成 测试,这样才能保证模型和控制器之间能够良好契合. 在 RSpec 中,这种测试称为功能测试(feature spec),有时也称为验收测试(acceptance te ...

  3. Confluence 6 嵌套用户组的备注

    潜在的性能影响.启用嵌套用户组可能会减慢用户查找的速度. 在 LDAP 中定义嵌套用户组.在 LDAP 中,一个嵌套用户组是 DN (Distinguished Name)的子用户组,这个字用户组将会 ...

  4. SQL 函数 DateDiff()

    DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]) 描述 返回两个日期之间的时间间隔. 语法 DateDiff( ...

  5. oaf 动态创建table vo (转)

    原文地址:如何动态创建table 需求: 因为系统中有几千个QA plan 但是不能手动创建几千个 质量收集页面所有需要根据 不同的plan 动态创建对应的 质量收集页面. 但是创建tabel 都要绑 ...

  6. dubbo监控中心搭建

    从网上下载了一个dubbo监控中心,地址忘了,文件名是dubbo-monitor-simple-2.5.3-assembly.tar.gz. 修改监控中心配置文件如下: dubbo.container ...

  7. 修改MAC地址的方法(未测试)

    用ioctl控制,通过SIOCGIFHWADDR获取MAC地址,SIOCSIFHWADDR设置MAC地址,不过在设 置MAC地址之前,要先把网卡down掉,设置好了以后,再UP起来. #include ...

  8. Sql Server约束的学习二(检查约束、默认约束、禁用约束)

    接上一篇的Sql Server约束学习一(主键约束.外键约束.唯一约束) 4.检查约束 1)检查约束的定义 检查约束可以和一个列关联,也可以和一个表关联,因为它们可以检查一个列的值相对于另一个列的值, ...

  9. bzoj1617

    题解: dp f[i]表示运i头奶牛需要的时间 f[i]=f[i-j]+a[i]+2*m 然后ans=f[n]-m(最后一次不用跑回来) 代码: #include<bits/stdc++.h&g ...

  10. 百视通与微软共同宣布9月在华发布Xbox One

    4月30日消息,百视通今日与微软共同宣布,于今年9月在华发布Xbox One.这是继百视通与微软2013年9月成立合资公司后,双方合作的又一进展. 微软副总裁,硬件及设计工作室部门主管尤瑟夫 •梅赫迪 ...