Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ztransform - Bode plot problem

Status
Not open for further replies.

bmalp

Electrical
Jan 4, 2007
4
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
 
Replies continue below

Recommended for you

If your ztrans answer is correct, then the amplitude in your plot must be correct. Do you think it is too bigor too small? What do you think the correct answer is?

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?
 
Hi Visigoth,

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

 
Yes, and continue to look at the denominator. The trick that a pole does is to be able to divide by a very small number, thus making the answer very large. As the denominator approaches zero the result approaches infinity. In your case the denominator is:
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.

 
VisiGoth,

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
 
Why not? A tone in the time domain shuld be an impulse in the frequency domain. We are only looking at a finite time discrete approximation. And the z transform domain Bode plot looks very much like an impulse. An impulse in the frequency domain means there is a tone at that frequency. I see the frequency domain has a tone at about 0.1, which is your frequency! That is perfect. If you increase the resolution of the plot, say using 1024 pointsi instead of 256 you will see the max a little lower than 0.1 exactly. I think htat has to do with the natural frequency and damping of this particular approximation.

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.

 
In short, I expect in the frequency domain a correct display of frequency AND amplitude.

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?

 
Aha, you expect that the amplitude in the frequency domain matches the max of the abs of an instant in time in the amplitude in the time. I think that is a false assumption. You might consider that the area under the impulse in the frequency domain might match the energy in the time domain, or something like that. The area under the impulse might be one.

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor