📄 ex6_3.m
字号:
%%%%%%%%%%%%%%%%%% Example 6.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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ---- Response of a lowpass digital filter ----
%
clear
disp('Example 6.3')
Ts = 0.01; % sampling period
G = tf(0.325*[1 0.5385],[1 -0.5],Ts) % create lowpass filter
w = logspace(-2,0,50)*pi/Ts; % specify frequency range
figure
bode(G,w),grid % frequency response plot
title('Bode plot for Example 6.3')
disp('Click on the frequency response curves to find')
disp('frequency response values')
disp('******>'), pause
t = [0:Ts:10.0-Ts]; % time array from 0 to 9.99 sec
e = cos(14*pi*t)+cos(50*pi*t)+cos(86*pi*t); % DT signal
y = lsim(G,e); % filter output
t9 = [901:1000]';
figure
subplot(2,1,1) % split graphics window
stem(t(t9),e(t9),':'), grid
title('Input and output signals for Example 6.3')
axis([9.5 10.0 -4 4]) % show only last 0.5 s
legend('Input signal')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(2,1,2)
stem(t(t9),y(t9),':*'), grid
axis([9.5 10.0 -4 4]) % show only last 0.5 s
legend('Output signal')
xlabel('Time (s)')
ylabel('Amplitude')
disp('******>'), pause
N = length(y(t9)); % number of data points
Yp = fft(y(t9))/N; % Compute Fourier Series Coeffs
ff = [0:1/Ts/N:(1.0-Ts)/Ts]; % frequency array
figure
stem(ff,abs(Yp),'*');grid % magnitude plot
ylabel('Magnitude')
xlabel('Frequency (Hz)')
title('Magnitudes of output Fourier-series coeffs for Example 6.3')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -