Remove noise from the signal below and plot the original signal less noise.
y=[2.75428, 5.71513, 4.74625, 4.0357, 3.58133, 4.29361, 3.17913,3.96698, 4.947, 2.50101, 5.18169, 2.42088, 4.19325, 5.36498, 3.02793,5.3784, 2.79834, 5.13506, 5.43307, 5.70375, 4.02817, 3.45414,3.15312, 3.77185, 3.1477, 3.61882, 4.29079, 1.62228, 5.45282,5.21009, 2.99312, 3.5315, 2.37493, 4.56933, 3.66105, 2.94791,4.00497, 5.01201, 2.42359, 3.34126, 2.95821, 1.60697, 2.69763,3.32045, 4.58761, 3.78392, 1.14806, 1.12364, 2.98555, 1.68054,2.34178, 0.954301, 2.95354, 1.85866, 0.70389, 2.74476, 1.86708,2.5442, 2.26406, 0.984498, 3.01632, 2.65318, 0.928562, 2.69881,1.08165, 2.03826, 3.19213, 4.30941, 1.39572, 3.1275, 2.88962,4.00469, 3.20351, 2.21581, 1.29336, 3.77378, 0.952478, 1.04008,1.25416, 1.67683, 3.71773, 3.11416, 3.59578, 1.28689, 1.28631,1.03774, 3.23732, 3.15302, 4.76595, 3.5586, 4.6036, 3.40278, 3.93159,0.996068, 2.28392, 3.97436, 1.31199, 3.37306, 1.59347, 4.81479,4.98611, 2.97305, 4.99383, 3.80786, 1.95455, 4.56209, 2.11904,3.26038, 1.42664, 4.30224, 3.67952, 4.92539, 1.49919, 1.60278,3.95577, 2.42314, 2.48873, 1.54822, 2.63348, 3.43014, 2.17739,3.19454, 2.07749, 3.67022, 2.26272, 1.30863, 2.18551, 4.97789,1.43625, 1.88595, 1.21594, 2.87569, 1.17509, 2.75502, 2.71201,3.12858, 4.85521, 2.33088, 3.93246, 1.87746, 3.53247, 1.94075,2.44728, 3.5839, 2.47802, 3.85354, 1.45955, 0.983903, 1.264, 3.57013,0.273807, 0.978381, 0.770786, 2.59596, -0.0634878, 2.94635, 0.40255,0.609216, 1.95247, 0.503754, 0.189706, 2.87551, 2.57051, 3.12867,1.11012, 1.33686, 0.473327, -0.158264, 2.87489, 1.67097, -0.85459,-1.06732, 1.62827, 2.06016, -1.22761, 1.79616, 0.640145, -0.812508,-1.50028, -1.54575, -0.217228, 2.06445, -0.0252311, 1.31984,-1.09519, -1.55624, 0.602962, 1.33464, 0.883919, 0.142988, -0.886204,0.426426, 0.893315, 1.30856, -1.24124, 0.239628, 1.96819, 1.91064,-1.39036, 1.02973, -0.120615, 1.24169, -1.40214, 1.03507, -1.46984,1.58711, 1.01167, 2.08498, 1.97875, 1.48291, -1.26303, -0.930141,-0.59183, -0.350317, 1.93194, 0.953808, 0.829422, 0.662458, 1.50385,-0.943274, 1.21817, 1.12564, 1.28737, 0.4419, -0.222186, 2.34941,1.18368, 1.9319, -0.194216, 3.35556, 2.80241, 2.51639, 0.537432,0.625744, 2.86291, 2.28998, 4.0202, 3.9159, 3.92103, 0.377672,2.28483, 2.40107, 1.61928, 0.578327, 4.38002, 0.645356, 3.7589,3.62083, 4.1443, 1.89589, 2.23305, 1.4046, 4.11185, 2.37104, 3.31836,2.83245];
Here is the python code. Run it in anypython compiler by copy and pasting this code. Play with N and Wn to find the desired result.
import scipy.signal as signal
# Design the Buterworth filter
N = 3 # This is the Filter order
Wn = 0.1 # This says about Cutoff frequency
B, A = signal.butter(N, Wn, output='ba')
smooth_data = signal.filtfilt(B,A, y)
plt.plot(y,'r-')
plt.plot(smooth_data,'b-', label = 'Filter order= 3 and cutoff
freqency = 0.1')
plt.legend()
plt.show()
if needed some further details of writing the code ask in the comment section.
Get Answers For Free
Most questions answered within 1 hours.