Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do z transform using python sympy?

z transform is very important in signal process. I can find fourier, laplace, cosine transform and so on in sympy tutorial. But I do not know how to do z transform using sympy. Could you tell me how to do it ?

like image 888
artzers Avatar asked Apr 06 '17 06:04

artzers


2 Answers

SymPy doesn't have it implemented as a transform function yet, but you can represent the summations directly. However, after some playing with it, it looks it is limited in what sums it can actually compute. Here's an example of one that works:

>>> pprint(summation(n*z**-n, (n, -oo, oo)))
⎧      z           1           │1│
⎪- ───────── + ──────────  for │─│ < 1 ∧ │z│ < 1
⎪          2            2      │z│
⎪  (-z + 1)      ⎛    1⎞
⎪              z⋅⎜1 - ─⎟
⎪                ⎝    z⎠
⎪
⎨        ∞
⎪       ___
⎪       ╲
⎪        ╲      -n
⎪        ╱   n⋅z                 otherwise
⎪       ╱
⎪       ‾‾‾
⎩      False
like image 121
asmeurer Avatar answered Sep 25 '22 08:09

asmeurer


There is a nice package (lcapy) which is based on sympy but can do z transform and inverse and a lot more other time discrete stuff.

https://pypi.org/project/lcapy/

Simply try

import lcapy as lc
from lcapy.discretetime import n

xk=n*2**n*lc.exp(3j*n)
X0=xk.ZT()
print(X0)
like image 32
Emi Avatar answered Sep 22 '22 08:09

Emi