Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

python language data txt file contents: 0.000000000000000000e+00 1.539222746762192351e+01 4.399208505782237211e-03 -1.307295274049445677e+00 8.015716473555293931e+00 -1.281714644970376682e+00 3.688694036249841268e+00 1.664335986527485645e+01 1.461770195531442162e+00 -1.873839914438522491e+00 1.927609380497408864e+01 1.493254677558604726e+01 3.076879347054811475e+00 1.124908693577696894e+01 5.949357911560769097e+00 1.005042101449891589e+00 2.039644049876629950e+01 1.834909587412036913e+01 -1.074156825573327367e+00

python language

image text in transcribedimage text in transcribeddata txt file contents:

0.000000000000000000e+00 1.539222746762192351e+01 4.399208505782237211e-03 -1.307295274049445677e+00 8.015716473555293931e+00 -1.281714644970376682e+00 3.688694036249841268e+00 1.664335986527485645e+01 1.461770195531442162e+00 -1.873839914438522491e+00 1.927609380497408864e+01 1.493254677558604726e+01 3.076879347054811475e+00 1.124908693577696894e+01 5.949357911560769097e+00 1.005042101449891589e+00 2.039644049876629950e+01 1.834909587412036913e+01 -1.074156825573327367e+00 8.888370894941111544e+00 1.654362868616317428e+01 3.605454012563596322e+00 7.987292411134694348e+00 1.067904374377847532e+01 -3.498774922564585665e+00 7.088708253288592331e+00 2.088948435052724051e+01 1.328896772892835809e+00 -6.353232791922378553e+00 5.639147652116234255e+00

Often data measured in the real word is noisy. So we need to apply some kind of filter to clean up the data. In this question we are going to write a function that applies the "1-2-1" filter. The "1-2-1" filter maps each point of data to the average of itself twice and its neighbors. For example, if at some point our data contained ...1, 4, 3... then after applying the "1-2-1" filter the 4 would be replaced with (1+4+4+33) 4 = 3 12 We get a nice smooth looking wave function representing our signal. Write a function plot_filtered_signal(filename, n) that takes the name of a file containing data for a noisy signal and plots a smoothed version of the signal after applying the "1-2-1" filter n times. The file will contain a list of data samples each 0.1 ms apart. There is one sample (a floating-point value) on each line of the file. You should label your plot as is shown in the image above. The data for the signal in the above plots can be downloaded here. Notes: To apply the filter n times, you should apply it once to get a new signal, then apply it again to get another new signal, and so on, for a total of n times. It is safest to create a new array on each iteration; attempting to perform the filtering "in-place" on the same array will probably give you the wrong results. The last sample in the array has an x-value of (len(array) - 1) / 10 ms, not len(array) / 10 ms. You should call the plot function with an array of time values and an array of y values. There are more efficient ways of heavily smoothing a signal than to apply this simple filter a large number of times. You'll learn about these if you do a signal processing course in your degree

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions