hey. I keep getting an error for this code. If anyone could help me it would be greatly appreciated.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sachini Perera
el 6 de Oct. de 2021
Respondida: Paul
el 6 de Oct. de 2021
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 comentarios
Respuesta aceptada
C B
el 6 de Oct. de 2021
Editada: C B
el 6 de Oct. de 2021
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 comentarios
Más respuestas (1)
Paul
el 6 de Oct. de 2021
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 comentarios
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!