%z_filter_imp.m
%Z域表示的數字濾波器的回應舉例
%H(Z)={Z^2 + 2Z + 1}/{Z^3 -0.5Z^2 -0.005Z^-1 +0.3}
%初始狀態 y(-1)= 1, y(0) = -1.
clc;
clear;
close all;
b=[0 1 2 1 0]; %分子系數
a=[1 -0.5 0 0.3 -0.005]; %分母系數
figure;
freqz(b,a,8);
figure;
subplot(421);
zplane(b,a); %繪制零極點圖
title('系統的零極點圖');
subplot(422);
impz(b,a,21);
title('單位脈沖回應');
subplot(423);
stepz(b,a,21);
title('單位階躍回應');
%給定激勵,求零輸入回應、零狀態回應,全回應
N=21;
n=0:N-1;
x=exp(-0.6*n); %激勵信號:指數衰減信號
x0=zeros(1,N); %全零:零狀態回應時作為全零狀態
y0=[1,-1]; %初始狀態(條件)
xi=filtic(b,a,y0); %求零輸入回應時的等效初始條件
y1=filter(b,a,x0,xi); %求零輸入回應
xi0=filtic(b,a,0); %求零狀態回應的等效初始條件
y2=filter(b,a,x,xi0); %零狀態回應
y3=filter(b,a,x,xi); %完全回應
[h w]=freqz(b,a,21); %由Z域傳遞函式求頻率回應函式(21個點)
subplot(424);
stem(n,y1);
title('零輸入回應');
grid on;
subplot(425);
stem(n,y2);
title('零狀態回應');
grid on;
subplot(426);
stem(n,y3);
title('系統的全回應');
grid on;
%繪制頻率回應曲線
subplot(427);
plot(w,abs(h));
title('幅頻特性曲線');
grid on;
subplot(428);
plot(w,angle(h));
title('相頻特性曲線');
grid on
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/261816.html
標籤:其他
