生成周期sin
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了生成周期sin相关的知识,希望对你有一定的参考价值。
def generateSin(amplitude,frequency,phase,x): return [x,amplitude * math.sin(x * frequency + phase)] print [generateSin(10, 1, 0, x) for x in range(10)] ''' [[0, 0.0], [1, 8.4147098480789655], [2, 9.0929742682568175], [3, 1.4112000805986722], [4, -7.5680249530792825], [5, -9.5892427466313848], [6, -2.7941549819892586], [7, 6.5698659871878906], [8, 9.8935824662338181], [9, 4.1211848524175663]] ''' #this will flatten the list print sum([generateSin(10, 1, 0, x) for x in range(10)],[]) ''' [0, 0.0, 1, 8.4147098480789655, 2, 9.0929742682568175, 3, 1.4112000805986722, 4, -7.5680249530792825, 5, -9.5892427466313848, 6, -2.7941549819892586, 7, 6.5698659871878906, 8, 9.8935824662338181, 9, 4.1211848524175663] '''
以上是关于生成周期sin的主要内容,如果未能解决你的问题,请参考以下文章