Why Does My Z-Transform Bode Plot Show Incorrect Amplitude for a Sine Wave?

In summary, the conversation discusses visualizing a sine wave that has been z-transformed in a Bode plot. The frequency is correct, but the amplitude is much larger than expected. The speaker suggests using a specific website for help with MATLAB.
  • #1
bmalp
1
0
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
 
Physics news on Phys.org
  • #2
Last edited by a moderator:
  • #3


Hello Bmalp,

Thank you for sharing your code and question. It seems like you are on the right track with your z-transform and Bode plot. However, there are a few things that could be causing the incorrect amplitude in your plot.

Firstly, make sure that your frequency w is in the correct units. In your code, you have set w = 0.1, but it is not clear what unit this is in. If you are trying to plot a sine wave with a frequency of 0.1 Hz, then w should be set to w = 2*pi*0.1 = 0.2. This could be one reason why your amplitude is off.

Secondly, check that your time step Ts is correct. In your code, you have set Ts = 1, which means that your sampling frequency is 1 Hz. If you are trying to plot a sine wave with a frequency of 0.1 Hz, then your sampling frequency should be at least 2*0.1 = 0.2 Hz. Try increasing your sampling frequency and see if that improves the amplitude in your plot.

Lastly, it is important to note that the z-transform and Bode plot are not the same as a Fourier transform and frequency plot. The z-transform is a discrete-time equivalent of the Laplace transform, and the Bode plot is used to visualize the frequency response of a system, which is not the same as the frequency content of a signal. So, while your code may give you a rough idea of the frequency response of your system, it may not accurately represent the amplitude of your sine wave.

I hope this helps and gives you some things to consider as you continue to work on your code. Good luck!
 

1. What is a Matlab z-transform Bode plot?

A Matlab z-transform Bode plot is a graphical representation of the frequency response of a system modeled using the z-transform in Matlab. It shows the magnitude and phase response of a system over a range of frequencies.

2. How do I create a Matlab z-transform Bode plot?

To create a Matlab z-transform Bode plot, you first need to define your system using the z-transform functions in Matlab. Then, you can use the bode function to generate the plot. Make sure to specify the frequency range and any other necessary parameters.

3. What is the difference between a magnitude and phase plot in a Matlab z-transform Bode plot?

The magnitude plot in a Matlab z-transform Bode plot shows the amplitude response of a system at different frequencies, while the phase plot shows the phase shift caused by the system at those frequencies. Together, they give a complete picture of the frequency response of the system.

4. Can I customize the appearance of a Matlab z-transform Bode plot?

Yes, you can customize the appearance of a Matlab z-transform Bode plot by changing the line colors, styles, and markers, as well as the plot title, axes labels, and grid lines. You can also add annotations and legends to the plot.

5. What can I learn from a Matlab z-transform Bode plot?

A Matlab z-transform Bode plot can provide valuable insights into the frequency response of a system, such as the dominant frequencies, resonance points, and stability of the system. It can also help in designing and optimizing systems for specific frequency ranges.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top