ex6_2.m

来自「离散控制系统设计的MATLAB 代码」· M 代码 · 共 35 行

M
35
字号
%%%%%%%%%%%%%%%%%% Example 6.2 %%%%%%%%%%%%%%%%%%
%   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                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   ---- Sinusoidal Steady-State Response ----
%
clear
disp('Example 6.2')

Ts = 0.01                            % sampling time
k = [0:1:20]';                       % generate time window
kTs = k*Ts;
e = 5*cos(32*pi*kTs + 30*pi/180);    % input signal
num = 0.2066*[1 2 1];                % Butterworth filter numerator
den = [1 -0.3695 0.1958];            % Butterworth filter denominator
G = tf(num,den,Ts)                   % lti object
y = lsim(G,e);                       % simulate time response
[mag,ph] = bode(G,32*pi);            % mag and phase at w0
yss = 5*mag*cos(32*pi*kTs + (30+ph)*pi/180);  % eqn 6.3

figure
plot(kTs,e,'o:',kTs,y,'*:',kTs,yss,'v:') % plot all three signals
axis([0 0.2 -6 8])                   % change axis to allow space for legend
legend('input e(k*Ts)','filter output','steady-state output')
grid
hold on
plot(kTs,0*kTs)		                 % show horizontal axis as solid line
hold off
xlabel('Time (s)')
ylabel('Amplitude')
title('Input, complete, and steady-state signals for Example 6.2')
%%%%%%%%%%

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?