Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

C B
C B am 6 Okt. 2021
Bearbeitet: C B am 6 Okt. 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?

Weitere Antworten (1)

Paul
Paul am 6 Okt. 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));

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by