hey. I keep getting an error for this code. If anyone could help me it would be greatly appreciated.
2 次查看(过去 30 天)
显示 更早的评论
clear;
clc;
a = [1,12];
b = [1,15,54];
rt = tf(a,b);
% b) Determine the steady state errors for the open-loop systems below with the following inputs: 8𝑢(𝑡), 8𝑡𝑢(𝑡), and 8𝑡2𝑢(𝑡).
syms s;
num = a;
den = poly2sym(b,s);
gs = num/den;
es = 8/(1+lim(gs)); % Steady-state error with step input
er = 8/(lim(s*gs)); % Steady-state error with ramp input
ep = 8/(lim(s^2*gs)); % Steady-state error with parabola input
fprintf('b) Determine the steady state errors:\n\t\t with step input = %.3f,\n\t\t with ramp input = %.3f,\n\t\t with parabola input = %.3f\n', es, er, ep)
%% User-defined functions
function y = lim(f)
syms s;
y = limit(f,s,0);
if isnan(y)
y = inf;
end
end
0 个评论
采纳的回答
C B
2021-10-6
编辑:C B
2021-10-6
It was because value of (1+lim(gs)) was
a=(1+lim(gs))
a =
[55/54, 11/9]
clear;
clc;
a = [1,12];
b = [1,15,54];
rt = tf(a,b);
% b) Determine the steady state errors for the open-loop systems below with the following inputs: 8𝑢(𝑡), 8𝑡𝑢(𝑡), and 8𝑡2𝑢(𝑡).
syms s;
num = a;
den = poly2sym(b,s);
gs = num/den;
es = 8./(1+lim(gs)); % Steady-state error with step input
er = 8./(lim(s*gs)); % Steady-state error with ramp input
ep = 8./(lim(s^2*gs)); % Steady-state error with parabola input
fprintf('b) Determine the steady state errors:\n\t\t with step input = %.3f,\n\t\t with ramp input = %.3f,\n\t\t with parabola input = %.3f\n', es, er, ep)
%% User-defined functions
function y = lim(f)
syms s;
y = limit(f,s,0);
if isnan(y)
y = inf;
end
end
Is output as per expectation?
0 个评论
更多回答(1 个)
Paul
2021-10-6
Should num also use poly2sym? Otherwise, gs is 1 x 2 transfer function matrix, which may be what you want, but maybe not.
If you really do want gs to be 1 x 2, then you need to change the divide to dot-divide for es and er and ep.
es = 8./(1+lim(gs)); % was es = 8/(1+lim(gs));
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!