×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ztransform - Bode plot problem

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

RE: ztransform - Bode plot problem

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?

RE: ztransform - Bode plot problem

(OP)
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

RE: ztransform - Bode plot problem

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.

RE: ztransform - Bode plot problem

(OP)
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

RE: ztransform - Bode plot problem

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.

RE: ztransform - Bode plot problem

(OP)
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?

RE: ztransform - Bode plot problem

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources