# Matlab is not giving the correct z transform of - (n*a^n)*u[- n - 1];

24 visualizzazioni (ultimi 30 giorni)
juan il 30 Gen 2024
Commentato: juan il 31 Gen 2024
My code is:
syms n z a;
y = -(n*a*n)*heaviside(-n-1) ... heaviside is supposed to be the unit function but apparently it's not working.
yz = ztrans(y, n, z);
And the result I get everytime is 0... The correct answer must be (a*z^-1) / (1 - a*z^-1)^2
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Torsten il 30 Gen 2024
syms n z a
y = n*a^n;
yz = ztrans(y, n, z)
yz =
Now multiply numerator and denominator by z^-2.

Accedi per commentare.

### Risposta accettata

VBBV il 30 Gen 2024
syms n z a;
y = (n*a^n)*heaviside(n+1) %... heaviside is supposed to be the unit function but apparently it's not working.
y =
yz = ztrans(y, n,z)
yz =
simplify(yz)
ans =
##### 2 CommentiMostra NessunoNascondi Nessuno
VBBV il 30 Gen 2024
There is a typo error in the input function
y = (n*a^n)*heaviside(n+1) % equivalent expression
% ^ instead of power , you have a multiplier symbol
juan il 31 Gen 2024
I can't believe I didn't notice that typo...

Accedi per commentare.

### Più risposte (1)

Paul il 30 Gen 2024
Modificato: Paul il 31 Gen 2024
In addition to what @VBBV said about a typo in the defintion of y[n], there are two other fundamental problem that needs to be addressed.
The first problem is that, by default, the heaviside is not the discrete-time unit step for integer values of its argument, because for n = 0 with default sym preferences
sympref('default');
heaviside(sym(0))
ans =
So the first thing we need to do is change that from the default
sympref('HeavisideAtOrigin',1);
heaviside(sym(0))
ans =
1
Here's y, with the corrected typo
syms n z a
y(n) = -(n*a^n)*heaviside(-n-1) % heaviside is supposed to be the unit function but apparently it's not working.
y(n) =
Evaluate y for some values of n
[-3:3; y(-3:3)]
ans =
It's clear that y(n) = 0 for n >= 0.
However, the function ztrans is the unilateral z-transform and ignores all values of y for n < 0. So ztrans is basically computing the z-transform based only on n >=0, and in that range y(n) = 0 which is why ztrans returned zero. What you really need is the bilateral z-transform for a strictly left-sided (or non-causal) signal. You can get that using ztrans and one rule from a standard z-transform table.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Calculus in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by