【发布时间】:2019-08-22 22:15:47
【问题描述】:
我有这段代码生成以下(图像),我将如何继续检测线与函数的交叉点?`
import numpy as np
import matplotlib.pyplot as plt
y = 0.4*np.ones(100)
x = np.arange(0, 100)
t = np.linspace(0,100,100)
Fs = 6000
f = 200
func = np.sin(2 * np.pi * f * t / Fs)
idx = np.where(func == y) # how i think i should do to detect intersections
print(idx)
plt.plot(x, y) # the horizontal line
plt.plot(t,func) # the function
plt.show()
【问题讨论】:
-
这简直等价于
func(t) - y = 0的求解题。对于您在此处给出的函数,解决方案是周期性的。
标签: python-3.x math signal-processing