Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Usually recorded data contains some noise associated with it. Figure 1 is an exa

ID: 3738928 • Letter: U

Question

Usually recorded data contains some noise associated with it. Figure 1 is an example of a pulse signal that contains noise as demonstrated by the scratchy appearance throughout the signal. One method to reduce the noise in the signal is to apply an averaging filter.

Figure 1 An averaging filter replaces each value in the signal with the average of the corresponding value with a specified number of surrounding values. For example:

If the original signal has values of [9 10 2 6 7 14 15 4 14 15] and the specified number of values to average is 3:

the 1st element in the averaged signal will be zero since there are not enough points to average (element 1±1 for a total of 3 data points)

the 2nd element in the averaged signal will be the average of the first three elements of the original signal: (9+10+2) /3 = 7

the 3rd element in the averaged signal will be the average of the next three elements of the original signal: (10+2+6) /3 = 6

The signal after being averaged should be [0 7 6 5 9 12 11 11 11 0] where the zeros at the ends are corresponding to signal values that do not have enough surrounding points to calculate their averages.

In your script file, write a program to apply an averaging filter to the signal stored in the file signal.mat. Your program must load the signal from your current folder. Your program should prompt the user for the number of data points to be averaged as an odd number bigger than 1. If the user enters an invalid number, the program must display an error message and re-prompt the user to enter in the number of data points to be averaged.

The program must apply an averaging filter such that the total number of averaged points is equal to the number specified by the user centered on a given point. You may use the floor() function to determine the number of data points on either side of the central data point to use. All elements in the averaged signal that do not have enough data points surround them to average should be set to zero.

Visualize your results using the following commands:

subplot(2,1,1); plot(originalSignal);

subplot(2,1,2); plot(averagedSignal);

You may test your script with the following numbers in the command window:

a) 1, 4 and 10

b) 3, 5, and 7

I would like the script file for this in matlab

Explanation / Answer

%if there is any problem, please tell in comments load signal.mat;%you havent provided the structure of data in signal.mat, %so i am assuming it is stored as a vector signal. If it isnt, please tell in comments how %it is stored so i can modify the code k=1; while k==1 k=0; n=input('Enter data points to average: '); if (mod(n,2)~=1)||(n