📄 vgain.m
字号:
function Kv = vgain(system)
% Computes the velocity error constant Kv given the
% transfer function of a system.
%Inputs: system - lti object
%Output: Kv - velocity error constant
%
% See also DCGAIN
%%%%%%%%%%%%%%%%%%% vgain.m %%%%%%%%%%%%%%%%%%%%%
% 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 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[num,den,Ts] = tfdata(system,'v');
den = small20(den,eps);
num = small20(num,eps);
len_den = length(den);
len_num = length(num);
%
if Ts == 0 % continuous-time system
if den(len_den) ~= 0 % constant term in den not zero
% ie, no integrator
disp('System is type-0, Kv = 0')
Kv = 0;
else
disp('System type is greater than or equal to 1')
Kv = num(len_num)/den(len_den-1);
end
else % discrete-time system
if abs(sum(den)) > 1e-10 % no pole at z=1
disp('System is type-0, Kv = 0')
Kv = 0;
else
disp('System type is greater than or equal to 1')
system1 = tf([1 -1],[1 0],Ts);
system2 = system*system1;
Kv = dcgain(system2);
end
end
return
%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -