? 設計計算機程序狱杰,產生序列并計算序列的DTFT屹耐,繪制其幅頻特性和相頻特性曲線;根據(jù)系統(tǒng)的單位脈沖響應和差分方程畦浓,計算系統(tǒng)的頻率響應痹束,繪制系統(tǒng)頻率響應的幅頻特性和相頻特性曲線;根據(jù)系統(tǒng)的單位脈沖響應和差分方程讶请,計算系統(tǒng)的系統(tǒng)函數(shù)祷嘶、零極點分布;改變系統(tǒng)的零極點分布夺溢,觀察系統(tǒng)頻率響應的變化论巍。
? 圖太多啦,就不貼出來了风响,自己跑吧嘉汰。
%1.設置差分方程y(n)-0.8y(n-1) = x(n)
a = 0.8;
%初值y(-1)?=0
ys = 0;
N = 30;
xn1 = [1,zeros(1,N-1)];
n =[1:N];
%輸入序列xn2
xn2 =0.8.^n;
B = 1;A= [1, -0.8];
xi =filtic(B,A,ys);
%2.求解系統(tǒng)的單位脈沖相應和輸入序列的單位脈沖相應
yn1 =filter(B,A,xn1);
yn2 =filter(B,A,xn2);
n1 =0:length(yn1)-1;
n2 =0:length(yn2)-1;
subplot(3,2,1);stem(n1,yn1,'.');
title('系統(tǒng)單位脈沖響應');xlabel('n');ylabel('h(n)');
subplot(3,2,2);stem(n2,yn2,'.');
title('輸入序列響應(函數(shù)庫法)');xlabel('n');ylabel('s(n)');
%3.dtft
w = -2*pi:0.01:2*pi;
X = dtft(xn2, n, w);
subplot(3,2,3); plot(n, xn2);title('signal = 0.8^n');
subplot(3,2,4); plot(w, X); title('DTFT');
%4.幅頻相頻特性
X1 = abs(X)
X2 = angle(X)
subplot(3,2,5); plot(w,X1); title('幅頻特性');
subplot(3,2,6); plot(w,X2); title('相頻特性');
%%%%%%%%%%%%%%%%%%%%%%%%根據(jù)系統(tǒng)
%H(Z)=Z/(Z-0.8)
num = [1];
den = [1,-0.8];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%零點極點分布
subplot(3,1,3);zplane(num,den);
%%%%%%%%%%%%%%%%改變零點極點的分布帶來的變化
w = -2*pi:0.01:2*pi;
%H(Z)=(Z-1)/(Z-0.8) 零點在單位圓上,谷值為0
num = [1,-1];
den = [1,-0.8];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%零點極點分布
subplot(3,1,3);zplane(num,den);
%H(Z)=(Z-0.7)/(Z-0.8) 1.零點越靠近單位圓,谷值越深
num = [1,-0.7];
den = [1,-0.8];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%零點極點分布
subplot(3,1,3);zplane(num,den);
%H(Z)=(Z-0.2)/(Z-0.8) 1.零點越靠近單位圓状勤,谷值越深
num = [1,-0.2];
den = [1,-0.8];
%響應分布
g = freqz(num,den,w');
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%零點極點分布
subplot(3,1,3);zplane(num,den);
%H(Z)=Z/(Z-0.3) 極點越靠近單位圓鞋怀,峰值越尖銳
num = [1];
den = [1,-0.3];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%H(Z)=Z/(Z-0.9) 極點越靠近單位圓,峰值越尖銳
num = [1];
den = [1,-0.9];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
%H(Z)=Z/Z-1 極點在單位圓上
num = [1];
den = [1,-1];
%響應分布
g = freqz(num,den,w);
figure;
g1 = abs(g)
g2 = angle(g)
subplot(3,1,1); plot(w,g1); title('幅頻特性');grid on;
subplot(3,1,2); plot(w,g2); title('相頻特性');grid on;
DTFT.m
function [ X ] = dtft(x,n,w)
% [X] = dtft(x持搜,n密似,w)
% X =在w頻率計算的DTFT值
% x = n上的有限持續(xù)時間序列
% n =樣本位置向量
% w =頻率位置矢量
temp = w'?* n;
temp =?- 1i? * temp;
e = exp(temp);
X = e *?x' ;
End
Ztrans.m
clear all;close all;clc;
syms k
xn3 = 0.8^k;
Fz = ztrans(xn3)?