我使用下面的python代码来偏置绝对的正弦波。我想只有波峰的波峰部分而不是波谷部分,即使在正偏置之后也是如此。在正偏置之后,我无法获得连续的波峰信号。任何人都可以帮助我吗?
用法:即使在动态移动阈值期间,也要保持输入信号高于阈值。
import matplotlib.pyplot as plt
import numpy as np
Bias=5;
x=np.linspace(-20,20,1000);
y=np.abs(np.sin(x)+Bias);
#Bias=np.zeros_like(x); # This is not working
y[(y<=Bias)]= Bias + y # This is not working
plt.plot(x,y)
plt.grid()
plt.show()
答案 0 :(得分:1)
有点不清楚你在问什么......也许你想试试这个:
import matplotlib.pyplot as plt
import numpy as np
Bias=5;
x = np.linspace(-20, 20, 1000);
y = np.abs(np.sin(x))
y = y + Bias
plt.plot(x, y)
plt.grid()
plt.show()
import matplotlib.pyplot as plt
import numpy as np
Bias=5;
x=np.linspace(-20,20,1000);
y=np.abs(np.sin(x) + Bias);
y[(y<=Bias)]= Bias
plt.plot(x,y)
plt.grid()
plt.show()