This question determine the static error constants, 𝐾𝑝, 𝐾𝑣, and 𝐾𝑎 of all the open-loop systems below and then determine the system types. But i keep getting an error.

33 views (last 30 days)
and below is the MATLAB i wrote.
a = [1,12];
b = [1,15,54];
rt = tf(a,b);
syms s; % Symbolic variable
num = a;
den = poly2sym(b,s);
gs = num/den; % Symbolic representation of OLTF
Kp = lim(gs); % Position constant, Kp
Kv = lim(s*gs); % Velocity constant, Kv
Ka = lim(s^2*gs); % Acceleration constant, Ka
fprintf('\nc) Determine the static error constants:\n\t\t Kp = %.3f,\n\t\t Kv = %.3f,\n\t\t Ka = %.3f\n', Kp, Kv, Ka)
checkSystemType(Kp,Kv,Ka);
disp (' ') % New line
%% User-defined functions
function y = lim(f)
syms s;
y = limit(f,s,0);
if isnan(y)
y = inf;
end
end
function checkSystemType(Kp,Kv,Ka)
if ~isinf(Kp) && Kv == 0 && Ka == 0
disp('System type: 0');
elseif isinf(Kp) && ~isinf(Kv) && Ka == 0
disp('System type: 1');
elseif isinf(Kp) && isinf(Kv) && ~isinf(Ka)
disp('System type: 2');
end
end

Answers (1)

Walter Roberson
Walter Roberson on 6 Oct 2021
You missed that a represents a polynomial.
a = [1,12];
b = [1,15,54];
rt = tf(a,b);
syms s; % Symbolic variable
num = poly2sym(a, s)
num = 
den = poly2sym(b,s)
den = 
gs = num/den % Symbolic representation of OLTF
gs = 
Kp = lim(gs) % Position constant, Kp
Kp = 
Kv = lim(s*gs) % Velocity constant, Kv
Kv = 
0
Ka = lim(s^2*gs) % Acceleration constant, Ka
Ka = 
0
fprintf('\nc) Determine the static error constants:\n\t\t Kp = %.3f,\n\t\t Kv = %.3f,\n\t\t Ka = %.3f\n', Kp, Kv, Ka)
c) Determine the static error constants: Kp = 0.222, Kv = 0.000, Ka = 0.000
checkSystemType(Kp,Kv,Ka);
System type: 0
disp (' ') % New line
%% User-defined functions
function y = lim(f)
syms s;
y = limit(f,s,0);
if isnan(y)
y = inf;
end
end
function checkSystemType(Kp,Kv,Ka)
if ~isinf(Kp) && Kv == 0 && Ka == 0
disp('System type: 0');
elseif isinf(Kp) && ~isinf(Kv) && Ka == 0
disp('System type: 1');
elseif isinf(Kp) && isinf(Kv) && ~isinf(Ka)
disp('System type: 2');
end
end

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!