Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6cbe066

Browse files
committed
Build list instead of concatenating strings
1 parente6dccbf commit6cbe066

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

‎control/xferfcn.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,38 +272,40 @@ def _repr_latex_(self, var=None):
272272
"""LaTeX representation of the transfer function, for Jupyter notebook"""
273273

274274
mimo=self.inputs>1orself.outputs>1
275+
275276
ifvarisNone:
276277
# ! TODO: replace with standard calls to lti functions
277278
var='s'ifself.dtisNoneorself.dt==0else'z'
278279

280+
out= ['$$']
281+
279282
ifmimo:
280-
outstr=r"$$\begin{bmatrix}"
281-
else:
282-
outstr="$$"
283+
out.append(r"\begin{bmatrix}")
283284

284285
foriinrange(self.outputs):
285286
forjinrange(self.inputs):
286287
# Convert the numerator and denominator polynomials to strings.
287288
numstr=_tf_polynomial_to_string(self.num[i][j],var=var)
288289
denstr=_tf_polynomial_to_string(self.den[i][j],var=var)
289290

291+
out+= [r"\frac{",numstr,"}{",denstr,"}"]
290292

291-
outstr+=r"\frac{"+numstr+"}{"+denstr+"}"
292293
ifmimoandj<self.outputs-1:
293-
outstr+="&"
294+
out.append("&")
295+
294296
ifmimo:
295-
outstr+=r"\\ "
297+
out.append(r"\\")
296298

297299
ifmimo:
298-
outstr+=r"\end{bmatrix}"
300+
out.append(r"\end{bmatrix}")
299301

300302
# See if this is a discrete time system with specific sampling time
301303
ifnot (self.dtisNone)andtype(self.dt)!=boolandself.dt>0:
302-
outstr+="\quad dt = "+self.dt.__str__()
304+
out+=["\quad dt = ",str(self.dt)]
303305

304-
outstr+="$$"
306+
out.append("$$")
305307

306-
returnoutstr
308+
return''.join(out)
307309

308310
def__neg__(self):
309311
"""Negate a transfer function."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp