Small error in example of documentation of signal.freqz?
Hi: The documentation of signal.freqz [1] has an example that plots the frequency response of a filter. The y axis is plotted in a logaritmic scale and labeled as "decibels": plt.semilogy(w, np.abs(h), 'b') plt.ylabel('Amplitude (dB)', color='b') I think that to be in dB, the plot should be in a linear scale and the magnitude of the response computed as 20*np.log10(np.abs(h)): plt.plot(w, 20*np.log10(np.abs(h)), 'b') plt.ylabel('Amplitude (dB)', color='b') Any comments? Alejandro [1] http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html
On 9/22/13, Alejandro Weinstein <alejandro.weinstein@gmail.com> wrote:
Hi:
The documentation of signal.freqz [1] has an example that plots the frequency response of a filter. The y axis is plotted in a logaritmic scale and labeled as "decibels":
plt.semilogy(w, np.abs(h), 'b') plt.ylabel('Amplitude (dB)', color='b')
I think that to be in dB, the plot should be in a linear scale and the magnitude of the response computed as 20*np.log10(np.abs(h)):
plt.plot(w, 20*np.log10(np.abs(h)), 'b') plt.ylabel('Amplitude (dB)', color='b')
Any comments?
You are correct. The y axis has a log scale, but the labels have the form 10^{n}, which are not dB values. Your change is reasonable, or the label could be changed to just "Gain". Warren
Alejandro
[1] http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
participants (2)
-
Alejandro Weinstein -
Warren Weckesser