python - Using Sine sample in a loop to per form calculation -
python - Using Sine sample in a loop to per form calculation -
i trying generate sine wave , sample , take each sample of , perform calculations using sample's value, save calculated value in array , plot output array against sine wave. however, not able below code.
def sampled_sine_wave(freq): samples = 1000 time_period = 1 time = linspace(0,time_period,samples) _ = plot(time,[sin(t*freq*2*np.pi) t in time]) vin=sampled_sine_wave if vin > 0: vpos=vin dw = (1 - numpy.exp(-(1-w)/1))*lamda*((eta1)* numpy.sinh(eta2*vpos) - (w/tau)) * dt elif vin < 0: vneg=vin dw = (1- numpy.exp(-w/0.3))*lamda*((eta1) * numpy.sinh(eta2*vneg) - (w/tau)) * dt current=((1-dw) * alpha * (1 - numpy.exp(-beta * vin)) + (dw * gamma * numpy.sinh(delta * vin)))
so, going explanation trying sample vin 0.001s timestep "dt" , @ particular time step compare vin's value greater or less 0 calculate "dw" , utilize "dw" calculate "current" , save calculated current in array plotted against corresponding point/sample vin.
so, can help me. in advance
you should import numpy first on top of page this:
from numpy import *
if don't have numpy modul can download here
python
Comments
Post a Comment