fre_fir1.m
来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 24 行
M
24 行
%==========================================================================
% Name:fre_fir.m
% The program compute the DTFT of discrete-time sequence x(n),
% and plot the curves.
%==========================================================================
clear;close all;
h=input('Type in the impulse response h(n)=');
N=length(h);
w=0:0.1:2*pi;Hg1=0;
for i=0:N-1
m=-N/2+i-0.5;
Hg=h(i+1)*cos((i-(N-1)/2)*w);
Hg1=Hg1+h(i+1)*cos((i-(N-1)/2)*w);
end
n=0:N-1;
subplot(2,1,1);stem(n,h,'.');grid on;
xlabel('Index n');ylabel('the curve of h(n)');
title('The frequence response of the filter h(n)');
subplot(2,1,2);plot(w/(pi),Hg1);grid on;axis([0,2,min(Hg1),max(Hg1)])
xlabel('w');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?