simple array calculation help

2 views (last 30 days)
Mahesh Sadupalli
Mahesh Sadupalli on 23 Apr 2021
Answered: Cris LaPierre on 23 Apr 2021
Write a program that will smooth an array of data using an exponential moving average. For the input data we assume a row vector with 𝑁 elements. We use the following expression for the average: Xavg,𝑘 = 𝛼X(𝑎v,𝑘−1) + (1 − 𝛼) ⋅ X𝑘, except for 𝑘 = 1, where X𝑎vg,1 = X1. You can use the following statement (for MATLAB) to create a row vector of data with noise from a normal distribution with a mean of 5.0 and a standard deviation of 3.0 to test your program:
1) inputData = 5.0 + 3.0 ∗ 𝑟andn(1,100);
2) 𝛼= 0.8
Please use only basic operators like assignment, comparison, conditional statement, and loops. Do not use built in functions or advanced possibilities of a specific programming language (e.g. vectorization in MATLAB).

Answers (1)

Cris LaPierre
Cris LaPierre on 23 Apr 2021
I suggest going through MATLAB Onramp

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!