ztransform - Bode plot problem
ztransform - Bode plot problem
(OP)
Hi,
I try to visualize a sine wave, z-transformed in a Bode plot. The frequency shows up correctly, but the amplitude is way off - why?
Thanks for your comments.
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))) % correct
if 0 % method 1
[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 % method 2
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)) % amplitude way too big
I try to visualize a sine wave, z-transformed in a Bode plot. The frequency shows up correctly, but the amplitude is way off - why?
Thanks for your comments.
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))) % correct
if 0 % method 1
[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 % method 2
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)) % amplitude way too big





RE: ztransform - Bode plot problem
I changed things to use more standard nomenclature and to eliminate redefining reserved variables. ss is a reserved variable. You should use j instead of sqrt( -1 ) when communicating with other engineers.
format compact
syms w Ts n z phi t fs f
Ts = 1
w = 0.1
phi = 0
vz = simplify( ztrans( sin( w * n * Ts + phi ) ) ) % correct
if 0 % method 1
[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 % method 2
fs = 1;
f = linspace( 0, fs, 256 );
w = 2 * pi * f;
s = j * w;
Z = exp( s / fs );
h = double( subs( vz, z, Z ) );
end
[ numVz, denVz ] = numden( vz )
sVz = solve( denVz, 'z' )
maxVzEst = abs( subs( vz, z, exp( j * cos( 1 / 10 ) * double( imag( sVz( 1 ) ) ) ) ) )
plot( w, abs( h ) ) % amplitude way too big
grid
So I get an estimate that could exceed
maxVzEst =
754.0016
Is this what you were looking for?
RE: ztransform - Bode plot problem
thanks for your reply and cleaning the code.
What amplitude I actually expect? Well, starting from
sin( w * n * Ts + phi ) I would expect min = -1 and max = 1, or an amplitude of 1, right?
The amplitudes obtained by both methods are a) different and b) simply wrong - why?
Regards,
Bmalp
RE: ztransform - Bode plot problem
denVz =
z^2-2*z*cos(1/10)+1
z is complex and we will only evaluate the result on the unit circle. So we will never go through a pole and thus not ever attain infinity (which is what a pole is). However, if you find the point on the unit circle that is closest to the pole you will find the maximum of the result. I found a point somewhat close to the pole just as an example to show you that the pole can shoot really high.
RE: ztransform - Bode plot problem
thanks for your explanations. They confirm that the sine wave is an unstable signal - it oscillates.
So we still have the situation that the z-transform of the sine being correct (confirmed from a transforms table), does not show up correctly in a Bode plot. How to get out of this dilemma?
A sine wave can be Fourier transformed and shown in the frequency domain, should this not be possible using the z-transform?
Bmalp
RE: ztransform - Bode plot problem
So I think the Bode plot is correct and you think it is incorect. I stated why I think it is correct enough, and I gave a qualitative, but not quantitative reason why the max did not appear at exactly 0.1.
What are your reasons? Just whaqt did you expect in the frequency domain? A perfect impulse?
Try this:
change w to:
w = pi / 10;
Then
f = linspace( 0, fs, 1001 );
You should get a near impulse Bode plot. I chose a privlidged frequency to plot.
RE: ztransform - Bode plot problem
As you said, the frequency shows up correctly.
But I wrote also in this thread that the amplitude is not correct (several hundreds instead of 1 for a simple sine wave).
So why is the amplitude off in a Bode plot when the transform itself is correct?
RE: ztransform - Bode plot problem
But I am an engineer, not a mathematician. So maybe I should care about that, but it does not have a practical aspect to me. I would trust the text books on this one.
So in conclusion, I would expect an impulse response in the frequency domain to represent a single frequency in the time domain. An impulse is infinite in amplitude and zero width. Roughly, so that zero time infinity is equal to one; at least in my humble engineering's explanation of the math world.