Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please, solve the following programming problem using MATLAB. Comment for which portion of code does what will be very much appreciated. 1. Smoothing filter A

Please, solve the following programming problem using MATLAB. Comment for which portion of code does what will be very much appreciated.

image text in transcribedimage text in transcribed

1. Smoothing filter A smoothing filter averages out rapid changes from a data set and is typically used to remove high-frequency fluctuations (e.g., measurement noise) from a signal or to reduce the amount of intensity variation between one pixel and the next one in images. In this task, you will design a smoothing filter by writing a custom function with the declaration: smoothed -CTask2pl (x, width) and save it in a file named CTask2p1 f.m. The filter should take a vector of noisy data (x)and smooth it by doing a symmetric moving average with a window of the specified width. For points near the beginning and the end of the data set, use a smaller number of samples on either side of the samples in the average calculation, but be sure to keep an equal number of samples on either side of the sample under test For example If width-5 and length (x)-100 Then or n-3:98, moothed (n) mean (x (n-2:n+2)) or nc3, smoothed (1)x(1) smoothed(2) -mean (x (1),x(2),X(3)); smoothed(99) smoothed (100)x(100) for n> 98, -mean (x(98),x(99).?(100)); Note: You must write your own code to implement the smoothing algorithm rather than use any built-in MATLAB functions such as smooth. Your code should also meet the following requirements: 1 The lengths of x and smoothed should be equal. 2) For symmetry to work, make sure that width is odd. If it isn't, increase it by 1 to make it odd and display a warning in command window, but still do the smoothing. 3) You can use a loop and mean (which should be easy but may be slow), or more efficiently by using conv (if you are familiar withconvolution). Write a new script called CTask2p1.m to test your function. Copy the following commands to the beginning of your script: 4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

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