ex2_8.m

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

M
30
字号
%%%%%%%%%%%%%%%%%% Example 2.8 %%%%%%%%%%%%%%%%%%%   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 to a piecewise-constant input ----%cleardisp('Example 2.8')numG = [2 -2.2 0.56];                  % numerator of G(z)denG = [1 -0.6728 0.0463 0.486];       % denominator of G(z)Ts = 0.2                               % sampling periodG = tf(numG,denG,Ts)                   % create TF object G(z)dtime = [0:Ts:8]';                     % discrete time samplesu = 2.0*ones(size(dtime));             % start with all input values = 2.0ii = find(dtime>=2.0);                 % use find cmd to get indices ofu(ii) = 0.5;                           % ...elements to be changedy = lsim(G,u,dtime);                   % compute response due to input ufigurestem(dtime,y,'filled'),grid            % plot response of G(z) due to uhold onplot(dtime,u,'o')                      % plot inputhold offtext(2.3,-1.8,'output')                % add labels to plottext(1.6,2.3,'input')title('Example 2.8')xlabel('Time (s)')%%%%%%%%%%

⌨️ 快捷键说明

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