mercredi 6 avril 2016

Random signal in python

I am trying to generate a random signal in python. The given time t is 10ms and voltage x should vary between the range -.5 v to .5v. the code I have tried is

import pylab
import random
import numpy as np

ampSize= 10

x = range(ampSize)
y = np.arange(0., 1., .1)
yNow = 0

for i in range(ampSize):
    newValue = random.uniform(-.5,.5)

pylab.plot(x,y)
pylab.show()`

I want to x values to be randomly generated between the given range.So far I am getting a linear straght line.




Aucun commentaire:

Enregistrer un commentaire