Why I have following error? unrecognized function or variable 'printsys'. Error at (line 5) printsys(num, den, 'z')

14 visualizaciones (últimos 30 días)
clear all;
clc;
num=[0 1 5 4]; % nominator values
den=[1 -4 1 -2.5]; % denominator values
printsys(num, den, 'z')
[r,p,k]=residuez(num,den); % partial fraction expansion
zeros=roots(num); % to find the zeros values
poles=roots(den); % to find the poles values

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Dic. de 2021
Change
printsys(num, den, 'z')
to
disp(tf(num, den, 'z'))
  3 comentarios
Walter Roberson
Walter Roberson el 14 de Dic. de 2021
residuez() is from the Communication Systems Toolbox.
roots() is from basic MATLAB.
printsys() is part of the Control System Toolbox, but does not appear to be indexed in the documentation any more. It is in the portion of Control System Toolbox functions marked as "obsolete"
help printsys
PRINTSYS Print system in pretty format. PRINTSYS is used to print state space systems with labels to the right and above the system matrices or to print transfer functions as a ratio of two polynomials. PRINTSYS(A,B,C,D,ULABELS,YLABELS,XLABELS) prints the state-space system with the input, output and state labels contained in the strings ULABELS, YLABELS, and XLABELS, respectively. ULABELS, YLABELS, and XLABELS are string variables that contain the input, output and state labels delimited by spaces. For example the label string YLABELS=['Phi Theta Psi'] defines 'Phi' as the label for the first output, 'Theta' as the label for the second output, and 'Psi' as the label for the third output. PRINTSYS(A,B,C,D) prints the system with numerical labels. PRINTSYS(NUM,DEN,'s') or PRINTSYS(NUM,DEN,'z') prints the transfer function as a ratio of two polynomials in the transform variable 's' or 'z'. See also: PRINTMAT and POLY2STR.
It is not part of the Symbolic Toolbox.
You can simulate it using the Symbolic Toolbox:
num=[0 1 5 4]; % nominator values
den=[1 -4 1 -2.5]; % denominator values
printsys(num, den, 'z')
5*z + z^2 + 4 --------------------- z - 4*z^2 + z^3 - 5/2
function printsys(num, den, variable)
sv = sym(variable);
ns = char(poly2sym(num, sv));
n_ns = length(ns);
ds = char(poly2sym(den, sv));
n_ds = length(ds);
barlen = max(n_ns, n_ds);
fprintf('%s%s\n', blanks(floor((barlen-n_ns)/2)), ns);
fprintf('%s\n', repmat('-', 1, barlen));
fprintf('%s%s\n', blanks(floor((barlen-n_ds)/2)), ds);
end
You might notice that the coefficients are not in the standard order, with the powers increasing and then the constant last. This is caused by the char() operation that converts the symbolic expression generated by poly2sysm() to a character vector for display. The output of poly2sym() by itself looks fine, but to get the spacing right according to printsys(), we have to convert to character vectors -- we cannot generate the correct length of fraction bar without converting to character vectors.
It is possible to write code that (A) puts the coefficients in the standard order; and (B) gets the spacing the same as is used by printsys(); and (C ) gets the spacing right for subtractions; and (D) omits the multiplications between the constants and the symbols. Possible. And if you care to do that... go ahead ;-)
But probably by far the easiest thing is to install the Control System Toolbox in order to either use printsys() or tf()

Iniciar sesión para comentar.

Más respuestas (1)

Yerson
Yerson el 14 de Jun. de 2025
Unrecognized function or variable 'printsys'.
me aparece ese error que puedo hacer?
  1 comentario
Walter Roberson
Walter Roberson el 14 de Jun. de 2025
Editada: Walter Roberson el 14 de Jun. de 2025
You do not have the Control System Toolbox installed.
Although printsys() is marked as obsolete, it is still present as of R2025a.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by