The use of polynomial operations and symbolic expressions is very convenient, the following summarizes a number of commonly used functions, and attached to their own writing to transform the S-domain into the z-domain function
polynomial Operations
1.r=roots (p) polynomial root-finding
2.p3=conv (P1,P2) polynomial multiplication
3.p1=polyder (p) polynomial derivation
3.polyval (p,x) Polynomial surrogate evaluation
4.polyfit (x,y,n) polynomial-fitting
5. [R,p,k] =residue (b,a) Fractional expansion
Note: The functions of polynomial operations are represented by vectors, and note the difference between them and the symbolic expressions, which can be converted to each other poly2sym (), Sym2poly ()
Symbolic Operations
1.syms x, y, Z; Defining Symbolic variables
2.sym=poly2sym (P, ' s '); convert a polynomial vector to a symbolic expression
3.p=sym2poly (sym); convert symbolic expressions to polynomial vectors
4.[n,d]=numden (sym); Separating the symbolic expression from the numerator denominator
5.subs (Sym, ' x ', value) algebraic evaluation of symbolic expressions
6. Simplify (SYM) simplification
7.pretty (sym) Beautify output symbol expression
8.expand (SYM) expand
9.collect (sym) Merge
10.solve (SYM) solves the solution of sym=0.
function [numz,denz]=s2z (NUMS,DENS,TS)
%[NUMZ,DENZ]=S2Z (Nums,dens,ts)
% function: Transform s-domain transfer function to Z-domain
Input
%nums,dens continuous system with s as variable molecule, denominator polynomial
Output
%numz,denz discrete systems with Z as variable molecules, denominator polynomial
Syms t n s z;
Gs_num=poly2sym (Nums);
Gs_den=poly2sym (dens);
Gs=gs_num/gs_den;
Ft=ilaplace (Gs); % of continuous transfer Laplace inverse transformation
Gnt=subs (Ft,t,n*ts); % discretization
Gz=ztrans (GNT); %z Transform
[A,b]=numden (Gz); The%numden function separates the numerator of the symbolic expression from the denominator
Numz=sym2poly (a);
Denz=sym2poly (b);
End