快到龙抬头,居然下雪了,天空飘起了雪花,温度下降了近20°。

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 4.21 \n\n'); banner();
%% ------------------------------------------------------------------------ % ----------------------------------------------------
% 1 H1(z)
% ---------------------------------------------------- b = [3/4, 5/4, 1, 1, 5/4, 3/4]; a = [1]; % [R, p, C] = residuez(b,a) Mp = (abs(p))'
Ap = (angle(p))'/pi %% ------------------------------------------------------
%% START a determine H(z) and sketch
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P4.21 H(z) its pole-zero plot')
set(gcf,'Color','white');
zplane(b,a);
title('pole-zero plot'); grid on; %% ----------------------------------------------
%% END
%% ---------------------------------------------- % ------------------------------------
% h(n)
% ------------------------------------ [delta, n] = impseq(0, 0, 19);
h_check = filter(b, a, delta); % check sequence %% --------------------------------------------------------------
%% START b |H| <H
%% 3rd form of freqz
%% --------------------------------------------------------------
w = [-500:1:500]*2*pi/500; H = freqz(b,a,w);
%[H,w] = freqz(b,a,200,'whole'); % 3rd form of freqz magH = abs(H); angH = angle(H); realH = real(H); imagH = imag(H); %% ================================================
%% START H's mag ang real imag
%% ================================================
figure('NumberTitle', 'off', 'Name', 'P4.21 DTFT and Real Imaginary Part ');
set(gcf,'Color','white');
subplot(2,2,1); plot(w/pi,magH); grid on; %axis([0,1,0,1.5]);
title('Magnitude Response');
xlabel('frequency in \pi units'); ylabel('Magnitude |H|');
subplot(2,2,3); plot(w/pi, angH/pi); grid on; % axis([-1,1,-1,1]);
title('Phase Response');
xlabel('frequency in \pi units'); ylabel('Radians/\pi'); subplot('2,2,2'); plot(w/pi, realH); grid on;
title('Real Part');
xlabel('frequency in \pi units'); ylabel('Real');
subplot('2,2,4'); plot(w/pi, imagH); grid on;
title('Imaginary Part');
xlabel('frequency in \pi units'); ylabel('Imaginary');
%% ==================================================
%% END H's mag ang real imag
%% ================================================== % --------------------------------------------------------------
% x(n) through the filter, we get output y(n)
% --------------------------------------------------------------
N = 200;
nx = [0:1:N-1];
x = sin(pi*nx/2) + 5 * cos(pi*nx); [y, ny] = conv_m(h_check, n, x, nx); figure('NumberTitle', 'off', 'Name', 'P4.21 Input & h(n) Sequence');
set(gcf,'Color','white');
subplot(3,1,1); stem(nx, x); grid on; %axis([0,1,0,1.5]);
title('x(n)');
xlabel('n'); ylabel('x');
subplot(3,1,2); stem(n, h_check); grid on; %axis([0,1,0,1.5]);
title('h(n)');
xlabel('n'); ylabel('h');
subplot(3,1,3); stem(ny, y); grid on; %axis([0,1,0,1.5]);
title('y(n)');
xlabel('n'); ylabel('y'); figure('NumberTitle', 'off', 'Name', 'P4.21 Output Sequence');
set(gcf,'Color','white');
subplot(1,1,1); stem(ny, y); grid on; %axis([0,1,0,1.5]);
title('y(n)');
xlabel('n'); ylabel('y'); % ----------------------------------------
% yss Response
% ----------------------------------------
ax = conv([1,0,1], [1,2,1])
bx = conv([0,1], [1,2,1]) + conv([5,5], [1,0,1]) by = conv(bx, b)
ay = ax zeros = roots(by) [R, p, C] = residuez(by, ay) Mp_Y = (abs(p))'
Ap_Y = (angle(p))'/pi %% ------------------------------------------------------
%% START a determine Y(z) and sketch
%% ------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'P4.21 Y(z) its pole-zero plot')
set(gcf,'Color','white');
zplane(by, ay);
title('pole-zero plot'); grid on; % ------------------------------------
% y(n)
% ------------------------------------
LENGH = 100;
[delta, n] = impseq(0, 0, LENGH-1);
y_check = filter(by, ay, delta); % check sequence y_answer0 = 4.75*delta; [delta_1, n1] = sigshift(delta, n, 1);
y_answer1 = 2.25*delta_1; [delta_2, n2] = sigshift(delta, n, 2);
y_answer2 = 2.75*delta_2; [delta_3, n3] = sigshift(delta, n, 3);
y_answer3 = 3.75*delta_3; [delta_4, n4] = sigshift(delta, n, 4);
y_answer4 = 4.50*delta_4; y_answer5 = (2*(-0.5)*cos(pi*n/2) + 2*0.5*sin(pi*n/2) ).*stepseq(0,0,LENGH-1); [y01, n01] = sigadd(y_answer0, n, y_answer1, n1);
[y02, n02] = sigadd(y_answer2, n2, y_answer3, n3); [y03, n03] = sigadd(y01, n01, y02, n02);
[y04, n04] = sigadd(y03, n03, y_answer4, n4); [y_answer, n_answer] = sigadd(y04, n04, y_answer5, n); figure('NumberTitle', 'off', 'Name', 'P4.21 Yss and Y ');
set(gcf,'Color','white');
subplot(2,1,1); stem(n, y_answer5); grid on; %axis([0,1,0,1.5]);
title('Steady-State Response');
xlabel('n'); ylabel('Yss');
subplot(2,1,2); stem(n, y_check); grid on; % axis([-1,1,-1,1]);
title('Total Response');
xlabel('n'); ylabel('Y');

  运行结果:

系统函数H(z)的系数:

系统的DTFT,注意当ω=π/2和π时的振幅谱、相位谱的值。

当有输入时,输出的Y(z)进行部分分式展开,留数及对应的极点如下:

单位圆上z=-1处,极点和零点相互抵消,稳态响应只和正负j有关。

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

  1. 《DSP using MATLAB》Problem 6.21

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

  2. 《DSP using MATLAB》Problem 5.21

    证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  3. 《DSP using MATLAB》Problem 8.21

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

  4. 《DSP using MATLAB》Problem 3.21

    模拟信号经过不同的采样率进行采样后,得到不同的数字角频率,如下: 三种Fs,采样后的信号的谱 重建模拟信号,这里只显示由第1种Fs=0.01采样后序列进行重建,采用zoh.foh和spline三种方法 ...

  5. 《DSP using MATLAB》Problem 7.27

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

  6. 《DSP using MATLAB》Problem 7.26

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

  7. 《DSP using MATLAB》Problem 7.24

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

  8. 《DSP using MATLAB》Problem 7.23

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

  9. 《DSP using MATLAB》Problem 7.16

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

随机推荐

  1. http-server 基于nodejs的http服务器

    http-server所用场景: 作为前端的同学来说,想要运行一段代码,但又没有必要使用tomcat或是Apache http server,这个时候,一个简单的轻量的http-server就能搞定. ...

  2. 免费下载知网文献的方法 | sci-hub免费下载SCI论文方法

    部分方法参考自在家里如何免费使用中国知网? - 大学生 - 知乎的回答,已注明出处. 知网文献下载:idata中国知网 idata中国知网网址:idata中国知网 https://www.cn-ki. ...

  3. 常用HTTP contentType与后端处理方式

    常用HTTP contentType与后端处理方式 1.Content-Type:application/x-www-form-urlencoded; charset=UTF-8 前端export.j ...

  4. codeforces 555c// Case of Chocolate// Codeforces Round #310(Div. 1)

    题意:直角边为n的网格巧克力,一格为一块,选择斜边上一点,从左或上吃,直到吃到空气,称为一次操作.给出几个操作,问各能吃几块.如果x是当前要吃的横坐标,在已经吃过的中找x1>=x的第一个x1,即 ...

  5. Android出现declaration of org.apache.http.message.BasicLineFormatter appears in /system/framework/

    这是由于使用了CloseableHttpClient造成的,把 CloseableHttpClient httpclient = HttpClients.createDefault(); Closea ...

  6. pluck的返回值

    前言 今天用到了laravel的pluck功能,就顺便记录下来. pluck是获取所读取的数据一列或者两列的方法. 一.获取一列代码如下: ->pluck('pic_url') ; 结果如下: ...

  7. POJ-1129 Channel Allocation (DFS)

    Description When a radio station is broadcasting over a very large area, repeaters are used to retra ...

  8. Oracle 11g dataguard check RTA(real time apply)

    Oracle 11g dataguard check RTA(real time apply) 2017年8月24日 16:38 环境:oracle 11.2.0.1 OEL 5.8 注:以下操作都在 ...

  9. spring boot 学习(十四)SpringBoot+Redis+SpringSession缓存之实战

    SpringBoot + Redis +SpringSession 缓存之实战 前言 前几天,从师兄那儿了解到EhCache是进程内的缓存框架,虽然它已经提供了集群环境下的缓存同步策略,这种同步仍然需 ...

  10. spring boot 学习番外篇:超快速项目初始化

    超快速完成 Spring Boot 项目初始化 最近,在浏览 SPRING 官网时,发现一个超级方便的小工具,可以帮助我们快速创建一个 Spring Boot 项目,前提就是你能连接互联网. 依赖 支 ...