代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 3.20 \n\n'); banner();
%% ------------------------------------------------------------------------ %% -------------------------------------------------------------------
%% xa(t)=10cos(10000πt) through A/D
%% -------------------------------------------------------------------
Fs = 8000; % sample/sec
Ts = 1/Fs; % sample interval, 0.125ms=0.000125s n1_start = -80; n1_end = 80;
n1 = [n1_start:1:n1_end];
nTs = n1 * Ts; % [-10,10]ms [-0.01,0.01]s x1 = 10*cos(10000*pi*nTs); % Digital signal M = 500;
[X1, w] = dtft1(x1, n1, M); magX1 = abs(X1); angX1 = angle(X1); realX1 = real(X1); imagX1 = imag(X1); %% --------------------------------------------------------------------
%% START X(w)'s mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 3.20 X1');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magX1); grid on; %axis([-1,1,0,1.05]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,1,2); plot(w/pi, angX1/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 3.20 X1');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realX1); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagX1); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% --------------------------------------------------------
%% h(n) = (-0.9)^n[u(n)]
%% --------------------------------------------------------
n2 = n1;
h = (-0.9) .^ (n2) .* stepseq(0, n1_start, n1_end); figure('NumberTitle', 'off', 'Name', 'Problem 3.20 h(n)');
set(gcf,'Color','white');
%subplot(2,1,1);
stem(n2, h); grid on; %axis([-1,1,0,1.05]);
title('Impulse Response: (-0.9)^n[u(n)]');
xlabel('n'); ylabel('h'); [H, w] = dtft1(h, n2, M); magH = abs(H); angH = angle(H); realH = real(H); imagH = imag(H); %% --------------------------------------------------------------------
%% START H(w)'s mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 3.20 H');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magH); grid on; %axis([-1,1,0,1.05]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,1,2); plot(w/pi, angH/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 3.20 H');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realH); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagH); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% ----------------------------------------------
%% y(n)=x(n)*h(n)
%% ----------------------------------------------
[y, ny] = conv_m(x1, n1, h, n1); figure('NumberTitle', 'off', 'Name', 'Problem 3.20 y(n)');
set(gcf,'Color','white');
%subplot(2,1,1);
stem(ny, y); grid on; %axis([-1,1,0,1.05]);
title('x(n)*h(n)');
xlabel('n'); ylabel('y'); [Y, w] = dtft1(y, ny, M); magY = abs(Y); angY = angle(Y); realY = real(Y); imagY = imag(Y); %% --------------------------------------------------------------------
%% START Y(w)'s mag ang real imag
%% --------------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Y');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi,magY); grid on; %axis([-1,1,0,1.05]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,1,2); plot(w/pi, angY/pi); grid on; %axis([-1,1,-1.05,1.05]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Y');
set(gcf,'Color','white');
subplot(2,1,1); plot(w/pi, realY); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot(2,1,2); plot(w/pi, imagY); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% -------------------------------------------------------------------
%% END X's mag ang real imag
%% ------------------------------------------------------------------- %% ----------------------------------------------------------
%% xa(t) reconstruction from x1(n)
%% ---------------------------------------------------------- Dt = 0.00005; t = -0.01:Dt:0.01;
xa = x1 * sinc(Fs*(ones(length(n1),1)*t - nTs'*ones(1,length(t)))) ; figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Reconstructed From x1(n)');
set(gcf,'Color','white');
%subplot(2,1,1);
stairs(nTs*1000,x1); grid on; %axis([0,1,0,1.5]); % Zero-Order-Hold
title('Reconstructed Signal from x1(n) using zero-order-hold');
xlabel('t in msec.'); ylabel('xa(t)'); hold on;
stem(nTs*1000, x1); gtext('ZOH'); hold off; figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Reconstructed From x1(n)');
set(gcf,'Color','white');
%subplot(2,1,2);
plot(nTs*1000,x1); grid on; %axis([0,1,0,1.5]); % first-Order-Hold
title('Reconstructed Signal from x1(n) using first-Order-Hold');
xlabel('t in msec.'); ylabel('xa(t)'); hold on;
stem(nTs*1000,x1); gtext('FOH'); hold off; xa = spline(nTs, x1, t);
figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.20 Ts = %.6fs', Ts));
set(gcf,'Color','white');
%subplot(2,1,1);
plot(1000*t, xa);
xlabel('t in ms units'); ylabel('x');
title(sprintf('Reconstructed Signal from x1(n) using spline function')); grid on; hold on;
stem(1000*nTs, x1); gtext('spline'); %% ----------------------------------------------------------------
%% y(n) through D/A, reconstruction
%% ----------------------------------------------------------------
Dt = 0.00005; t = -0.02:Dt:0.02;
ya = y * sinc(Fs*(ones(length(ny),1)*t - (ny*Ts)'*ones(1,length(t)))) ; figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Reconstructed From y(n)');
set(gcf,'Color','white');
%subplot(2,1,1);
stairs(ny*Ts*1000,y); grid on; %axis([0,1,0,1.5]); % Zero-Order-Hold
title('Reconstructed Signal from y(n) using zero-order-hold');
xlabel('t in msec.'); ylabel('ya(t)'); hold on;
stem(ny*Ts*1000, y); gtext('ZOH'); hold off; figure('NumberTitle', 'off', 'Name', 'Problem 3.20 Reconstructed From y(n)');
set(gcf,'Color','white');
%subplot(2,1,2);
plot(ny*Ts*1000,y); grid on; %axis([0,1,0,1.5]); % first-Order-Hold
title('Reconstructed Signal from y(n) using first-Order-Hold');
xlabel('t in msec.'); ylabel('ya(t)'); hold on;
stem(ny*Ts*1000,y); gtext('FOH'); hold off; ya = spline(ny*Ts, y, t);
figure('NumberTitle', 'off', 'Name', sprintf('Problem 3.20 Ts = %.6fs', Ts));
set(gcf,'Color','white');
%subplot(2,1,1);
plot(1000*t, ya);
xlabel('t in ms units'); ylabel('y');
title(sprintf('Reconstructed Signal from y(n) using spline function')); grid on; hold on;
stem(1000*ny*Ts, y); gtext('spline');

  运行结果:

2、模拟信号经过Fs=8000sample/sec采样后,得采样信号的谱,如下图,0.75π处为假频。

脉冲响应序列如下:

系统的频率响应,即脉冲响应序列的DTFT:

输出信号及其DTFT:

3、第3小题中的模拟信号经Fs=8000采样后,数字角频率为π,

采样后信号的谱:

采样后信号经过滤波器,输出信号的谱,

4、找到另外两个不同的模拟角频率的模拟信号,使得采样后和第1小题模拟信号采样后稳态输出相同。

想求的数字角频率和第1题的数字角频率0.75π+2π,对应的模拟频率如下计算:

5、根据抽样定理,采用截止频率F0=4kHz,低通滤波器。

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

  1. 《DSP using MATLAB》Problem 6.20

    先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...

  2. 《DSP using MATLAB》Problem 5.20

    窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...

  3. 《DSP using MATLAB》Problem 4.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》Problem 7.24

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

  6. 《DSP using MATLAB》Problem 7.23

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

  7. 《DSP using MATLAB》Problem 6.15

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

  8. 《DSP using MATLAB》Problem 6.12

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

  9. 《DSP using MATLAB》Problem 6.10

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

随机推荐

  1. python通过get方式,post方式发送http请求和接收http响应-urllib urllib2

    python通过get方式,post方式发送http请求和接收http响应-- import urllib模块,urllib2模块, httplib模块 http://blog.163.com/xyc ...

  2. Tomcat 中文乱码 设置UTF-8编码 问题解决办法

    在Java Web开发中,http请求带有中文字符的URI如果不处理容易出现乱码问题:这是因为Tomcat容器默认编码是iso-8859-1引起的,因此要避免出现乱码就要需要做相应的处理.解决办法如下 ...

  3. 雷林鹏分享:Ruby 数据类型

    Ruby 数据类型 本章节我们将为大家介绍 Ruby 的基本数据类型. Ruby支持的数据类型包括基本的Number.String.Ranges.Symbols,以及true.false和nil这几个 ...

  4. English trip -- VC(情景课)1 E Writing

    Talk with a partner ['pɑːtnə] (伙伴)  与同伴说一说 Comple the words 写全单词 first second third last name area c ...

  5. 3.6 MIPS指令简介

    计算机组成 3 指令系统体系结构 3.6 MIPS指令简介 MIPS秉承着指令数量少,指令功能简单的设计理念.那这样的设计理念是如何实现的呢?在这一节,我们就将来分析MIPS指令的特点. 相比于X86 ...

  6. 42. Trapping Rain Water *HARD*

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  7. Centos7上部署openstack ocata配置详解

    之前写过一篇<openstack mitaka 配置详解>然而最近使用发现阿里不再提供m版本的源,所以最近又开始学习ocata版本,并进行总结,写下如下文档 OpenStack ocata ...

  8. SqlServer中的merge操作(转载)

    SqlServer中的merge操作(转载)   今天在一个存储过程中看见了merge这个关键字,第一个想法是,这个是配置管理中的概念吗,把相邻两次的更改合并到一起.后来在technet上搜索发现别有 ...

  9. bzoj1601

    题解: 简单生成树 代码: #include<bits/stdc++.h> using namespace std; ; int n,dis[N],f[N],a[N][N],ans; in ...

  10. 51nod1537

    题解: 预处理每一个要变换几次,然后改成每一个要改变的次数-上一个要改变的次数 然后对于区间[l,r]修改,就是l++,r+1++ dp即可(据说可以o(n)) 代码: #include<bit ...