cp5_3.m
来自「离散控制系统设计的MATLAB 代码」· M 代码 · 共 48 行
M
48 行
%%%%%%%%%%% Comprehensive Problem 5.3 %%%%%%%%%%%
% Discrete-Time Control Problems using %
% MATLAB and the Control System Toolbox %
% by J.H. Chow, D.K. Frederick, & N.W. Chbat %
% Brooks/Cole Publishing Company %
% September 2002 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- Anti-aliasing filters ----
%
clear
disp('Comprehensive Problem 5.3')
dt = 0.001; % time increment
tt = [0:dt:10-dt]; % continuous time
e = 5*cos(4*pi*tt) + 2*cos(18*pi*tt); % continuous-time signal
disp('Order of anti-aliasing filter')
n = 4
Ho = tf(10*pi,[1 10*pi])
Ho = ss(Ho);
H = 1;
for i = 1:n
H = H*Ho;
end
y = lsim(H,e,tt);
figure
kk = [9001:10000];
plot(tt(kk),e(kk),'--',tt(kk),y(kk)),grid
legend('input signal','output signal')
xlabel('Time (s)')
ylabel('Amplitude')
title('Input and output signals of the lowpass filter')
disp('Plot input and output signals of the lowpass filter')
disp('*****>'), pause
% sample y at 10 Hz
k = [9001:100:10000];
yfft = fft(y(k));
figure
f = [0:1:9]';
stem(f,abs(yfft)),grid
xlabel('Frequency (Hz)')
ylabel('Magnitude of Spectrum')
title('Spectrum of output signal')
disp('Plot spectrum of output signal')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?