user5603723
user5603723

Reputation: 193

Averaging an indefinite signal

I am trying to average a signal which is coming to my simulink model (unknown initial condition). I can pass on the first value as it is, But the 2nd value must be averaged with the first before passing it on and the must be averaged with the average of first two and so on. Can I just give initial condition as 0 for the first case?

But the problem is the length of the signal is unknown, I can keep getting signal until I run my program. I thought of moving average filter, but not sure how to proceed with this.

If anyone can point me in right direction.

Upvotes: 0

Views: 123

Answers (2)

jodag
jodag

Reputation: 22224

If you have the DSP System Toolbox then can use the Moving Average block. Turn off "Specify window length" to get the cumulative moving average.

Upvotes: 1

Ander Biguri
Ander Biguri

Reputation: 35525

You want a Cumulative moving average.

Its equation is quite simple

average=(newpoint+average*npoints)/(npoints+1);
npoits++

Upvotes: 0

Related Questions