Problem using variable='z^-1' in Z transform with Z^-1 format

5 views (last 30 days)
Hi Dears ,
What is the difference between one step and two step to define the 'variable'='z^-1'?
I want Z transform function 1/z^3 in term of z^-1 and the two step is ok not one step.
See the Matlab doc for tf, section: "Specify Polynomial Ordering in Discrete-Time Transfer Function"
num=[1];
den=[1 0 0 0];
% Two step is OK!
X1=tf(num,den,0.1)
X1.Variable='z^-1'
% One step is not OK!
X2=tf(num,den,0.1,'variable','z^-1')
X1 not equal X2
Many thanks to dear @Paul

Answers (2)

Walter Roberson
Walter Roberson on 30 Sep 2022
Setting the Variable property afterwards just changes the Variable property, without reinterpretting the matrices. It is not a conversion operation, it is just rewriting the label.

Paul
Paul on 15 Dec 2024
When specifying a tf in with Variable='z', the num and den are interpreted as being coefficients of descending powers of z
num=[1];
den=[1 0 0 0];
With default Variable = 'z' those mean
num(z) = 1*z^0
den(z) = 1*z^3 + 0*z^2 + 0*z^1 + 0*z^0
% Two step is OK!
X1=tf(num,den,0.1)
X1 = 1 --- z^3 Sample time: 0.1 seconds Discrete-time transfer function.
Now, when we switch the Variable,
X1.Variable='z^-1'
X1 = z^-3 Sample time: 0.1 seconds Discrete-time transfer function.
the num and den are converted to be coefficients of ascending powers of z^-1
X1.num{1} % 0*(z^-1)^0 + 0*(z^-1)^1 + 0*(z^-1)^2 + 1*(z^-1)^3 = z^-3
ans = 1×4
0 0 0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
X1.den{1} % 1*(z^-1)^0 + 0*(z^-1)^1 + 0*(z^-1)^2 + 0*(z^-1)^3 = 1
ans = 1×4
1 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
If we specify Variable = 'z^-1' from the outset in one step, we have to define num and den in ascending powers of z^-1
% One step is not OK!
%X2=tf(num,den,0.1,'variable','z^-1')
X2 = tf([0 0 0 1],1,0.1,'Variable','z^-1')
X2 = z^-3 Sample time: 0.1 seconds Discrete-time transfer function.
X1 - X2 % verify
ans = 0 Static gain.
  2 Comments
Walter Roberson
Walter Roberson on 16 Dec 2024
When the '^-1' variables are specified in the tf() call, the coefficients are stored internally in the reverse order. Meanwhile, setting the variable after the tf() is established changes the variable but does not alter the order of coefficients. So if you change the variable to z^(-1) after it defaulted to s, then the coefficients come out backwards because they are not automatically reversed when you set the variable after the tf() call.
Paul
Paul on 16 Dec 2024
Upon reflection, I agree with the first part of your comment because upon construction the num or den are appropriately zero padded so that numel(H.num{1}) == numel(H.den{1}). With that zero padding the coefficients are the same whether they be in terms of z or z^-1. I should have (and used to) know this. At construction we do have to keep in mind the difference between coefficients in descending powers of z and ascending powers of z^-1.
However, I'm not sure what you mean by the second part of your comment. Changing the variable from z^-1 to s results in an error
num = [0 1 3]; den = [1 2];
H = tf(num,den,-1,'Variable','z^-1')
H = z^-1 + 3 z^-2 ------------- 1 + 2 z^-1 Sample time: unspecified Discrete-time transfer function.
H.Variable = 's'
Error using ltipack.checkVariable (line 13)
The "Variable" property must be set to 's' or 'p' for continuous-time systems, and to one of the following: 'z', 'q', 'z^-1', or 'q^-1' for discrete-time systems.

Error in tf/set.Variable (line 473)
Value = ltipack.checkVariable(sys,Value);

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!