フィルターのクリア

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.

38 ビュー (過去 30 日間)
Sachini Perera
Sachini Perera 2021 年 10 月 6 日
コメント済み: Sachini Perera 2021 年 10 月 6 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 10 月 6 日
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

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by