3.2. DATAOBJECTS 73
As above, these polynomials can be specified by their roots or their coefficients. Note
that we can specify the variable,and for continuous systems we use “s”. To create a
discrete system “z” is used.
# Generate the system from the numerator and denominator
# coefficients.
numerator = makepoly([-.1,19.97,-7.02725],"s");
denominator = makepoly([1,0.3,0.2725],"s");
# We can also do this by specifying the roots of each
# polynomial
numerator = -0.1*polynomial([199.3475;0.3525],"s");
denominator = polynomial( ...
[-.15+0.5*jay;-.15-0.5*jay],"s");
# Note that multiplying the by -0.1 does the correct
# thing to the polynomial above. The final system is
# obtained with the command:
sys1 = numerator/denominator
Labeling and Comments
Xmath allows the user to label all the inputs, outputs and states in a state-space system.
Any Xmath variable can also havea comment string asso ciatedwith it.
Keywords for the system function are used to label the system. In the following
example, the two-input, single-output system generated above is used as the starting
point. Comments can be attached to anyvariable in the workspace (or the workspace
itself) with the comment command.
# Set up vectors of strings for the labels
inputs = ["disturbance";"actuator"]
outputs = ["measurement"]
states = ["x1";"x2"]
# and attach them to sys
sys = system(sys,inputNames = inputs,...
outputNames = outputs,...
stateNames = states)
# We can also attach a comment to sys
comment sys "Example system for the manual"