hey. I keep getting an error for this code. If anyone could help me it would be greatly appreciated.

1 view (last 30 days)
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

Accepted Answer

C B
C B on 6 Oct 2021
Edited: C B on 6 Oct 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?

More Answers (1)

Paul
Paul on 6 Oct 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));

Community Treasure Hunt

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

Start Hunting!