只放第1小题。

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 9.4.1 \n\n'); banner();
%% ------------------------------------------------------------------------ % ------------------------------------------------------------
% PART 1
% ------------------------------------------------------------ % Discrete time signal n1_start = 0; n1_end = 100;
n1 = [n1_start:1:n1_end]; xn1 = cos(0.15*pi*n1); % digital signal D = 4; % downsample by factor D
OFFSET = 0;
y = downsample(xn1, D, OFFSET);
ny = [n1_start:n1_end/D];
% ny = [n1_start:n1_end/D-1]; % OFFSET=2 figure('NumberTitle', 'off', 'Name', 'Problem 9.4.1 xn1 and y')
set(gcf,'Color','white');
subplot(2,1,1); stem(n1, xn1, 'b');
xlabel('n'); ylabel('x(n)');
title('xn1 original sequence'); grid on;
subplot(2,1,2); stem(ny, y, 'r');
xlabel('ny'); ylabel('y(n)');
title(sprintf('y sequence, downsample by D=%d offset=%d', D, OFFSET)); grid on; % ----------------------------
% DTFT of xn1
% ----------------------------
M = 500;
[X1, w] = dtft1(xn1, n1, M); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1);
max(magX1) %% --------------------------------------------------------------------
%% START X(w)'s mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 9.4.1 X1 DTFT');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magX1); grid on; %axis([-2, -1, -0.5, 0, 0.15, 0.5, 1, 2]);
title('Magnitude Response');
xlabel('digital frequency in \pi units'); ylabel('Magnitude |H|');
set(gca, 'xtick', [-2,-1.85,-1.5,-1,-0.15,0,0.15,0.5,1,1.5,1.85,2]);
subplot(2,1,2); plot(w/pi, angX1/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('digital frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 9.4.1 X1 DTFT');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realX1); grid on;
title('Real Part');
xlabel('digital frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagX1); grid on;
title('Imaginary Part');
xlabel('digital frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- % ----------------------------
% DTFT of y
% ----------------------------
M = 500;
[Y, w] = dtft1(y, ny, M); magY_DTFT = abs(Y); angY_DTFT = angle(Y); realY_DTFT = real(Y); imagY_DTFT = imag(Y);
max(magY_DTFT)
ratio = max(magX1)/max(magY_DTFT) %% --------------------------------------------------------------------
%% START Y(w)'s mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 9.4.1 Y DTFT');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, magY_DTFT); grid on; %axis([-2,2, -1, 2]);
title('Magnitude Response');
xlabel('digital frequency in \pi units'); ylabel('Magnitude |H|');
set(gca, 'xtick', [-2,-1.4,-1,-0.6,0,0.6,1,1.4,2]);
subplot(2,1,2); plot(w/pi, angY_DTFT/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('digital frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 9.4.1 Y DTFT');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realY_DTFT); grid on;
title('Real Part');
xlabel('digital frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagY_DTFT); grid on;
title('Imaginary Part');
xlabel('digital frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END Y's mag ang real imag
%% ------------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', sprintf('Problem 9.4.1 X1 & Y--DTFT of x and y, D=%d offset=%d', D,OFFSET));
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magX1); grid on; %axis([-1,1,0,1.05]);
title('Magnitude Response');
xlabel('digital frequency in \pi units'); ylabel('Magnitude |H|');
set(gca, 'xtick', [-2,-1.85,-1.4,-1,-0.6,-0.5,-0.15,0,0.15,0.5,0.6,1,1.4,1.85,2]);
set(gca, 'ytick', [-0.2, 0, 13.5, 20, 40, 51, 60]);
hold on;
plot(w/pi, magY_DTFT, 'r'); gtext('magY(\omega)', 'Color', 'r');
hold off; subplot(2,1,2); plot(w/pi, angX1/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('digital frequency in \pi units'); ylabel('Radians/\pi');
hold on;
plot(w/pi, angY_DTFT/pi, 'r'); gtext('AngY(\omega)', 'Color', 'r');
hold off;

  运行结果:

分两种情况

1、按照D=4抽取,offset=0

原始序列,抽取序列

原始序列的谱

抽取序列的谱

二者的DTFT混叠到一起,红颜色曲线是抽取序列的DTFT,可看出,其幅度大致为原始序列的谱幅度的1/4(精确值是1/3.7778)。

2、按照D=4抽取,offset=2

二者的DTFT混叠到一起,红颜色曲线是抽取序列的DTFT,可看出,其幅度大致为原始序列的谱幅度的1/4(精确值是1/4.0699)。

《DSP using MATLAB》Problem 9.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. <iframe>框架标签的使用

    同源下 1.iframe属性设置参考:https://blog.csdn.net/xiyiyindie/article/details/53415158 2.父子页面之间元素相互操作:https:// ...

  2. [bzoj1706]奶牛接力跑 题解 (矩阵快速幂(或者叫倍增Floyd?))

    Description FJ的N(2 <= N <= 1,000,000)头奶牛选择了接力跑作为她们的日常锻炼项目.至于进行接力跑的地点 自然是在牧场中现有的T(2 <= T < ...

  3. 配置ssh连接会话复用免密码登录

    我们经常使用ssh连接远程主机,为了方便,避免每次登录输入密码,通常使用密钥登录.如果没有设置密钥, 则需要使用密码登录了,若每次都输入密码则十分繁琐.我们可以设置ssh连接会话复用,则登录成功后,会 ...

  4. myeclipse 启动卡住的解决办法

    myeclipse 启动卡住的解决办法 今天启动myeclipse突然卡住,CPU一直占用,启动任务管理器强制关闭.重启myeclipse,重启电脑都不能够解决. 上网查找,在工程路径(工作空间的路径 ...

  5. [转] JPA 2.0 with EclipseLink - 教程

    原文: http://www.vogella.com/articles/JavaPersistenceAPI/article.html Lars Vogel Version 2.2 Copyright ...

  6. iptables防DDOS攻击和CC攻击配置

    防范DDOS攻击脚本 #防止SYN攻击 轻量级预防 iptables -N syn-flood iptables -A INPUT -p tcp –syn -j syn-flood iptables ...

  7. HDU 6659 Acesrc and Good Numbers (数学 思维)

    2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...

  8. zookeeper 同一docker伪集群

    1).集群目录 cd /usr/local/zookeeper01/data touch myid vi  输入 cd /usr/local/zookeeper01/data touch myid v ...

  9. springboot中引用配置文件中的参数

    首先可以看到这是做微信登陆时候的配置,一般不会写死都是通过配置文件获取,所以,记载配置文件中 那么怎么引用呢: 可以看到直接注入的方式就可以引用了,所以看下面: 进行页面跳转,并且带有参数的, 使用m ...

  10. 2019-5-16-WPF-光标初始化的时候-temp-文件夹满了无法创建

    title author date CreateTime categories WPF 光标初始化的时候 temp 文件夹满了无法创建 lindexi 2019-05-16 19:16:27 +080 ...