如何强制signal.sawtooth从0开始?(How to force the signal.sawtooth to start by 0?)

编程入门 行业动态 更新时间:2024-10-24 12:33:50
如何强制signal.sawtooth从0开始?(How to force the signal.sawtooth to start by 0?)

这可能是一个简单的伎俩,但我不会马上得到它。 我希望锯齿信号从(0,0)开始并上升一个周期的1/4,这样就像窦一样,而不是从(0,-1)开始。

from scipy import signal import matplotlib.pyplot as plt t = np.linspace(0, 1, 500) plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t))

it might be a simple trick, but I don't get it right away. I would like the sawtooth signal to start by (0,0) and go up for a 1/4th of a period so like a sinus would do instead of starting by (0,-1).

from scipy import signal import matplotlib.pyplot as plt t = np.linspace(0, 1, 500) plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t))

最满意答案

通过pi延迟相位

from scipy import signal import matplotlib.pyplot as plt t = np.linspace(0, 1, 500) plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t-np.pi)) plt.show()

只需在参数中添加-np.pi term即可

Delay the phase by pi

from scipy import signal import matplotlib.pyplot as plt t = np.linspace(0, 1, 500) plt.plot(t, signal.sawtooth(2 * np.pi * 5 * t-np.pi)) plt.show()

Just add -np.pi term in the argument

更多推荐

本文发布于:2023-08-04 00:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:sawtooth   signal   start   force

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!