from scipy.special import jv, yv
import numpy as np
import matplotlib.pyplot as plt
z = np.arange(-20,20,0.01)#x軸の範囲for i inrange(0,5):#次数の決定(別に何個でもいい)
bessel = (jv(i,z))
plt.plot(z,bessel,label="J"+str(i))
plt.legend()
plt.show()
nを横軸にしたグラフのコード
from scipy.special import jv, yv
import numpy as np
import matplotlib.pyplot as plt
z = np.arange(0,50,0.01)
x = []
bessel = []
jn = 0.5
jn_index = int(jn*100)
for i inrange(0,30):
bessel.append(jv(i,z[jn_index]))
x.append(i)
plt.xlabel("bessel order")
plt.ylabel("Jn(" +str(jn) + ")")
plt.scatter(x, bessel)
plt.show()
import numpy as np
defcreate_sin(amplitude,freq,frame,*,sampling = 48000):
data = np.zeros(frame,dtype = np.float)
for n in np.arange(1,frame):
sine = amplitude * np.sin(2 * np.pi * freq * n / sampling)
data[n] = sine
return data
defcreate_cos(amplitude,freq,frame,*,sampling = 48000):
data = np.zeros(frame,dtype = np.float)
for n in np.arange(1,frame):
cosine = amplitude * np.cos(2 * np.pi * freq * n / sampling)
data[n] = sine
return data
使い方
import audio_func as af
sinewave = cf.create_sin(1.0,1000,frame,sampling=48000)