Question: code so far fs = 1 0 0 dur = 1 3 tt 1 3 = np . arange ( 0 , dur, 1 /

code so far
fs=100
dur =13
tt13= np.arange(0, dur, 1/fs)
n13= tt13*fs
b13= np.array([1,1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1])
rect13=np.ones(len(tt13))
# nreceptions = number of receptions
# dur_reception is the total duration (seconds) of the reception that the signal pulse is embedded in
# datfile = name of data file to save receptions in
# First set sigpulse equal to whichever of the two pulses we want to use (b13 or rect13)
# and define the output data filename accordingly
# Uncomment the correct lines to make either the Barker or rectangular pulses
#sigpulse=b13
#datfile = 'proj_part2_data_barker13.npz'
sigpulse=rect13
datfile = 'proj_part2_data_rect13.npz'
# The settings below make 10 receptions all with an arrival time of 1.5 seconds
# Note that to increase or decrease the noise, change the noise_std variable (noise standard deviation)
nreceptions=10
starttime=0
arrivetime=1.5
indarrive=(np.rint(arrivetime*fs)).astype(int)
dur_reception=30
noise_std=0.05
# Initialize receptions matrix with zeros
receptions=np.zeros((nreceptions,dur_reception*fs))
# Create the signal piece (sigpulse embedded in a zero vector)
sigrecept=np.zeros(dur_reception*fs)
sigrecept[indarrive:indarrive+len(sigpulse)]=sigpulse
# For loop to generate receptions
for ind in range(0,nreceptions):
# Create the Gaussian random noise to add to signal
noiserecept=noise_std*np.random.standard_normal(len(sigrecept))
# Store in reception in array
receptions[ind,:]=sigrecept+noiserecept
# Save the data
np.savez(datfile,fs=fs,starttime=starttime,nreceptions=nreceptions,receptions=receptions)
# You can change the name of indatfile to reflect whatever data set you're using
indatfile=datfile
npz_file = np.load(indatfile)
fs=npz_file['fs']
starttime=npz_file['starttime']
nreceptions=npz_file['nreceptions']
receptions=npz_file['receptions']
plt.plot(receptions[0,:])
plt.plot(receptions[1,:])
plt.show()
code so far fs = 1 0 0 dur = 1 3 tt 1 3 = np .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!