# template for Lab #2, Task #2 import numpy import matplotlib.pyplot as p import channel reload(channel) import lab2 reload(lab2) # turn on interactive mode, useful if we're using ipython p.ion() # arguments: # channel -- instance of the channel.channel class # max_length -- integer # tol -- float # pad -- integer # return value: # a numpy array of length max_length or less def unit_sample_response(channel,max_length=1000,tol=0.005,pad=50): """ Returns sequence of samples that corresponds to the unit-sample response of the channel. The unit sample response should be calculated by computing the difference between shifted step responses, where the number samples in the step response should be "pad" more samples than needed in the calculation of the unit sample response (this eliminates end effects). The voltage sample sequence representing the unit sample response should truncated to the smallest length such that the maximum magnitude of the truncated samples are smaller than than "tol" times the value is the largest magnitude sample in the unit sample response. Please make sure that if tol=0.0, then the return USR should have length equal to max_length. IMPORTANT: Please read the hints in the lab handout before starting. """ pass # Your code here. if __name__ == '__main__': # Create the channels (noise free with no random delays # or padding) channel0 = channel.channel(channelid='0') channel1 = channel.channel(channelid='1') channel2 = channel.channel(channelid='2') # plot the unit-sample response of our three virtual channels lab2.plot_unit_sample_response(unit_sample_response(channel0), '0') lab2.plot_unit_sample_response(unit_sample_response(channel1), '1') lab2.plot_unit_sample_response(unit_sample_response(channel2), '2') # when ready for checkoff, enable the following line #lab2.checkoff(unit_sample_response,'L2_2')