Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pseudo-random input signal python

import numpy as np
import matplotlib.pyplot as plt

nstep = 300

# random signal generation

a_range = [0,2]
a = np.random.rand(nstep) * (a_range[1]-a_range[0]) + a_range[0] # range for amplitude

b_range = [2, 10]
b = np.random.rand(nstep) *(b_range[1]-b_range[0]) + b_range[0] # range for frequency
b = np.round(b)
b = b.astype(int)

b[0] = 0

for i in range(1,np.size(b)):
    b[i] = b[i-1]+b[i]

# Random Signal
i=0
random_signal = np.zeros(nstep)
while b[i]<np.size(random_signal):
    k = b[i]
    random_signal[k:] = a[i]
    i=i+1

# PRBS
a = np.zeros(nstep)
j = 0
while j < nstep:
    a[j] = 5
    a[j+1] = -5
    j = j+2

i=0
prbs = np.zeros(nstep)
while b[i]<np.size(prbs):
    k = b[i]
    prbs[k:] = a[i]
    i=i+1

plt.figure(0) 
plt.subplot(2,1,1)
plt.plot(random_signal, drawstyle='steps',label='Random Signal')
plt.legend()
plt.subplot(2,1,2)
plt.plot(prbs, drawstyle='steps', label='PRBS')
plt.legend()
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: sklearn model persistence 
Python :: python find matching string regardless of case 
Python :: django-filter field name greater than 
Python :: get users except superuser django 
Python :: UTC to ISO 8601 with Local TimeZone information without microsecond (Python 3): 
Python :: download python for windows 7 32-bit 
Python :: iterate rows 
Python :: accumulate sum of elements in list 
Python :: 4.3.3. Reassigning Variables 
Python :: round(len(required_skills.intersection(resume_skills)) / len(required_skills) * 100, 0) 
Python :: pyqt grid layout 
Python :: python access class property from string 
Python :: # sort the dictionary 
Python :: get weather data from weather underground 
Python :: splitting Feature and target using iloc 
Python :: turn index back to column 
Python :: auto reload exml odoo 13 
Python :: Command to import the Schema interface from voluptuous 
Python :: Grading program using if else 
Python :: unique character 03 
Python :: basic kivy md 
Python :: affochage dun index du array list a deux dimension 
Python :: build numpy array 
Python :: Broadcasting with NumPy Arrays Single dimension array Example 
Python :: display colors in python console 
Python :: Python NumPy asfortranarray Function Example array to fortanarray 
Python :: vocal remover source code python 
Python :: python pandas read parquet with progressbar 
Python :: python mxs Classof 
Python :: NumPy packbits Code Packed array along default axis 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =