# Confusion regarding Z-transform of unit step sequence in MATLAB

I am using MATLAB and trying to find ztransform of heaviside(n) which is unit step sequence

I am studying book Signals and Systems Laboratory with MATLAB Book by Alex Palamides and Anastasia Veloni

I have attached snap of book but when i try to run this code in MATLAB , i am not getting same results as book

My MATLAB code

clc;clear;close all
syms z n
f=heaviside(n)
X=ztrans(f,z)



If you look up Matlab's Heaviside function, you'll see that it is not equal to the unit step sequence $$u[n]$$, because, unlike $$u[n]$$, it returns the value $$1/2$$ for $$n=0$$. Hence, it is given by

$$h[n]=u[n]-\frac12\delta[n]\tag{1}$$

and, consequently, its $$\mathcal{Z}$$-transform is

$$H(z)=\frac{z}{z-1}-\frac12=\frac{1}{z-1}+\frac12$$

as correctly claimed by ztrans.

• Can you please explain, how you wrote H(z) = z/(z-1) -1/2 = 1/(z-1)+1/2 Commented May 12 at 13:17
• @DSP_CS: Have you tried to prove it yourself? Please give it a go, it's really absolutely basic. Commented May 12 at 13:47
• Got it. Thanks alot Commented May 12 at 17:43