Using Matlab, write a function called exp_average that computes the exponentially weighted moving average, or exponential average for short, of a sequence of scalars. The

Answered step by step
Verified Expert Solution
Question
22 users unlocked this solution today!

Using Matlab, write a function called exp_average that computes the exponentially weighted moving average, or exponential average for short, of a sequence of scalars. The input sequence is provided to the function one element at a time and the function returns the current average each time. If we denote the nth element of the input sequence, that is, the function input at the nth invocation, by inn, then the rule for calculating the corresponding average outn that is to be returned by the function is:

out1 = in1

outn = b

inn + (1 - b)

outn-1

where b is a coefficient between 0 and 1. You do not need to check b. In plain English, the current average depends on the current input and the previously computed average weighted by b and (1 - b), respectively. Here is how the function is expected to work. When called by two input arguments, the input sequence is reset, the first input argument is considered to be in1 and the second input argument is the value of the coefficient b. When called with a single input argument, it is considered to be int, that is, the current value of the input sequence. In both cases, the output is calculated according to the formula above. If the function is called for the very first time with a single input argument, the value of the coefficient b must default to 0.1. Hint: you should use two persistent variables to store the output and the coefficient b.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Link Copied!

Step: 1

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

100% Satisfaction Guaranteed-or Get a Refund!

Step: 2Unlock detailed examples and clear explanations to master concepts

blur-text-image_2

Step: 3Unlock to practice, ask and learn with real-world examples

blur-text-image_3

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

  • tick Icon Access 30 Million+ textbook solutions.
  • tick Icon Ask unlimited questions from AI Tutors.
  • tick Icon Order free textbooks.
  • tick Icon 100% Satisfaction Guaranteed-or Get a Refund!

Claim Your Hoodie Now!

Recommended Textbook for

flashcard-anime

Study Smart with AI Flashcards

Access a vast library of flashcards, create your own, and experience a game-changing transformation in how you learn and retain knowledge

Explore Flashcards

Students Have Also Explored These Related Databases Questions!