@@ -272,38 +272,40 @@ def _repr_latex_(self, var=None):
272
272
"""LaTeX representation of the transfer function, for Jupyter notebook"""
273
273
274
274
mimo = self .inputs > 1 or self .outputs > 1
275
+
275
276
if var is None :
276
277
# ! TODO: replace with standard calls to lti functions
277
278
var = 's' if self .dt is None or self .dt == 0 else 'z'
278
279
280
+ out = ['$$' ]
281
+
279
282
if mimo :
280
- outstr = r"$$\begin{bmatrix}"
281
- else :
282
- outstr = "$$"
283
+ out .append (r"\begin{bmatrix}" )
283
284
284
285
for i in range (self .outputs ):
285
286
for j in range (self .inputs ):
286
287
# Convert the numerator and denominator polynomials to strings.
287
288
numstr = _tf_polynomial_to_string (self .num [i ][j ],var = var )
288
289
denstr = _tf_polynomial_to_string (self .den [i ][j ],var = var )
289
290
291
+ out += [r"\frac{" ,numstr ,"}{" ,denstr ,"}" ]
290
292
291
- outstr += r"\frac{" + numstr + "}{" + denstr + "}"
292
293
if mimo and j < self .outputs - 1 :
293
- outstr += "&"
294
+ out .append ("&" )
295
+
294
296
if mimo :
295
- outstr += r"\\ "
297
+ out . append ( r"\\" )
296
298
297
299
if mimo :
298
- outstr += r" \end{bmatrix}"
300
+ out . append ( r" \end{bmatrix}")
299
301
300
302
# See if this is a discrete time system with specific sampling time
301
303
if not (self .dt is None )and type (self .dt )!= bool and self .dt > 0 :
302
- outstr += "\quad dt = " + self .dt . __str__ ()
304
+ out += [ "\quad dt = " , str ( self .dt )]
303
305
304
- outstr += "$$"
306
+ out . append ( "$$" )
305
307
306
- return outstr
308
+ return '' . join ( out )
307
309
308
310
def __neg__ (self ):
309
311
"""Negate a transfer function."""