《DSP using MATLAB》Problem 3.20


代码:
%% ------------------------------------------------------------------------
%% 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的更多相关文章
- 《DSP using MATLAB》Problem 6.20
		
先放子函数: function [C, B, A, rM] = dir2fs_r(h, r); % DIRECT-form to Frequency Sampling form conversion ...
 - 《DSP using MATLAB》Problem 5.20
		
窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...
 - 《DSP using MATLAB》Problem 4.20
		
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
 - 《DSP using MATLAB》Problem 2.20
		
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
 - 《DSP using MATLAB》Problem 7.24
		
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
 - 《DSP using MATLAB》Problem 7.23
		
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
 - 《DSP using MATLAB》Problem 6.15
		
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
 - 《DSP using MATLAB》Problem 6.12
		
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
 - 《DSP using MATLAB》Problem 6.10
		
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
 
随机推荐
- Linux中查看各文件夹大小(扫盘)
			
df -h ./ du -hs ./ du -h /ifs4/BC_RD/USER/lizhixin/my_project/human_chr22 | grep [[:digit:]+]G du [- ...
 - android------adb命令 pull或push手机和电脑文件交互
			
先说一下adb命令配置,如果遇到adb不是内部或外部命令,也不是可运行的程序或批量文件.配置下环境变量 1.adb不是内部或外部命令,也不是可运行的程序或批量文件. 解决办法:在我的电脑-属性-高级计 ...
 - php--------文件夹文件拷贝和复制
			
php开发中常常对文件进行操作,文件夹和文件的拷贝,复制等. /** * 文件夹文件拷贝 * * @param string $src 来源文件夹 * @param string $dst 目的地文件 ...
 - Oracle性能诊断艺术-读书笔记(脚本dbms_xplan_output截图-非常好的)
 - dp入门:最长不下降序列
			
#include "bits/stdc++.h" using namespace std; ],dp[]; int main() { int n; cin >> n; ...
 - golang channel本质——共享内存
			
channel是golang中很重要的概念,配合goroutine是golang能够方便实现并发编程的关键.channel其实就是传统语言的阻塞消息队列,可以用来做不同goroutine之间的消息传递 ...
 - 李阳音标速成MP3文本
			
第一节:前元音 No. 1 [i:]穿针引线长衣音,简称"长衣音" 字母:e字母:ee 字母:ea字母:ie字母:ei 其发音要领是发音时舌尖抵下齿,前舌尽量抬高.舌位高于/i/: ...
 - python自动化运维之路04
			
装饰器 装饰器(decorator)是一种高级Python语法.装饰器可以对一个函数.方法或者类进行加工.在Python中,我们有多种方法对函数和类进行加工,比如在Python闭包中,我们见到函数对象 ...
 - npm install mysql --save-dev
			
npm install X: 会把X包安装到node_modules目录中 不会修改package.json 之后运行npm install命令时,不会自动安装X npm install X –sav ...
 - Oracle sqlloader
			
一.SQL*LOADER简介 SQL*Loader是oracle提供的可以从多种平面文件中向数据库中加载数据的工具,使用sqlldr工具可以在很短的时间内向数据库中加载大量的数据,像把制作好的exce ...