📄 reinf6_7.m
字号:
%%%%%%%%%%% Reinforcement Problem 6.7 %%%%%%%%%%%
% 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 highpass digital filter ----
%
clear
disp('Reinforcement Problem 6.7')
Ts = 0.01; % sampling period
G = tf(3.077*[1 -0.5],[1 0.5385],Ts) % highpass filter
w = logspace(-2,0,50)*pi/Ts; % specify frequency range
figure
bode(G,w) % frequency response plot
title('Bode plot for Reinforcement Problem 6.7')
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),':','filled'), grid
legend('Input signal')
axis([9.5 10.0 -4 5]) % show only last 0.5 s
xlabel('Time (s)')
subplot(2,1,2)
stem(t(t9),y(t9),':o'), grid
axis([9.5 10.0 -12 12]) % show only last 0.5 s
legend('Output signal')
xlabel('Time (s)')
title('Input and output signals for Reinforcement Problem 6.7')
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 Reinforcement Problem 6.7')
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -