# z-transform of sin(w*t) - Matlab

Started by January 3, 2007
```Hi,

below I have two methods to calculate the frequency response of a
z-transformed sine signal. Neither of them gives the correct amplitude -
why?

Thanks,
Bmalp

function zdemo

format compact
syms w Ts  n  z phi t

Ts  = 1
w   = 0.1
phi = 0

vz = simplify(ztrans(sin(w*n*Ts+phi)))

if 0
[num,den] = numden(simplify(vz));
num = collect(num,'z')
den = collect(den,'z')
num1 = sym2poly(num)
den1 = sym2poly(den)
[h,w] = freqz(num1,den1,512,'whole');
else
fs = 1;
f = linspace(0,fs,256);
w = 2*pi*f;
ss = sqrt(-1)*w;
Z = exp(ss/fs);
h = double(subs(vz,z,Z));
end
plot(w,abs(h))

```
```bmalp wrote:

> Hi,
>
> below I have two methods to calculate the frequency response of a
> z-transformed sine signal. Neither of them gives the correct amplitude -
> why?

The z-transform of a sampled sine wave has a pole pair at exp(+ / - j
w0), where w0 is the frequency of the sine wave. Perhaps Matlab has
difficulties returning the value Infinity?

Regards,
Andor

```
```bmalp wrote:

> Hi,
>
> below I have two methods to calculate the frequency response of a
> z-transformed sine signal. Neither of them gives the correct amplitude -
> why?
>
> Thanks,
> Bmalp
>
First and foremost, because a signal cannot have a response.

Systems have responses, but systems are not responses.  Responses are
signals, not systems.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```>First and foremost, because a signal cannot have a response.
>
>Systems have responses, but systems are not responses.  Responses are
>signals, not systems.
>

By definition - yes. But generally Matlabs freqz returns the Bode plot
correctly. The symbolic solution of the z-transform is correct also. So I
suspect more the evaluation of the signal or "response". I will compare
with a sampled signal instead of a symbolic one.
```