Should ztrans Work Better when Using heaviside() ?

2 views (last 30 days)
Paul on 27 Oct 2022
Commented: Paul on 28 Oct 2022
Recently ran across peculiar behavior with ztrans.
Define some variables
syms n integer
syms T positive
Set sympref so that heaviside[n] is the discrete-time unit step
Simple function to take the z-tranform of a signal and then the inverse z-transform, which should return the input signal
g = @(f) [ztrans(f) ; simplify(iztrans(ztrans(f)))];
1. Simple case, works as expected
g([cos(n) sin(n)])
ans = 
2. Introduce symbolic sampling period, still works fine.
g([cos(T*n) sin(T*n)])
ans = 
3. Multiply the simple case by heaviside[n], which shouldn't have any material effect because heaviside[0] = 1
g([cos(n) sin(n)]*heaviside(n))
ans = 
It has no material effect, but we can see that ztrans is accounting for the possibility that heaviside[0] might not be 1, so it appears to be using the general rule
y[n] = f[n]*heaviside[n] = f[0]*heaviside[0]*kroneckerDelta[n] + f[n]*u[n-1]
where u[n] is the discrete-time unit step. The z-transform is then
Y(z) = f[0]*heaviside[0] + Z(f[n+1])/z
As an aside, it seems like it would be easier to solve by
y[n] = f[n]*heaviside[n] = f[n] + (f[0]*heaviside[0] - f[0])*kroneckerDelta(n)
Y(z) = Z(f[n]) - f[0]*h[0]
4. Now introduce the sampling period and heaviside. Based on 2 and 3 above, it would appear that the ztrans should be easily found as would the iztrans.
g([cos(T*n) sin(T*n)]*heaviside(n))
ans = 
But, in neither case is the closed form expression returned for the z-transform. Oddly, iztrans returns the closed form expression for cos, but not for sin.
Paul on 28 Oct 2022
Hi David,
% since the sympref setting is remembered after a session
% (I found that out the hard way).
I too am a member of that club. I put
into my startup.m script and then modify as needed.
Your results with the complex exponentials make the (lack of) results with sin and cos even more puzzling.

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by