Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?


Asked by harish bharadwaj on 24 May 2011


how to calculate summation of absolute value of incoming digital data over a cycle period for example 64 samples in a cycle using matlab or simulink

∑abs|d1(k)| for k=0 to 64



No products are associated with this question.

2 Answers

Answer by Laura Proctor

Laura Proctor (view profile)

on 24 May 2011
d = randn(64,1);
s = sum(abs(d))

1 Comment

Lisa Justin

Lisa Justin (view profile)

on 22 Feb 2012

what about the interval?

Laura Proctor

Laura Proctor (view profile)

Answer by Mark Biesiada

Mark Biesiada (view profile)

on 24 May 2011

There are a couple options available:

  • You could chain a series of 64 unit delays together and run a branched signal off of each one into a summation block.
  • You could use MATLAB function block ("Embedded MATLAB" in older releases) and have something in the body like:
function y = avg64( u )
persistent x;
if( isemtpy( x ) == true )
  x = zeros( 64, 1 );
x = [ abs(u), x( 2 : end ) ];
y = x;
  • I believe that the communication blockset has some buffer blocks that will accumulate a rolling set of samples, which you could then feed to a sum block.
  • There is probably a way to write this as a transfer function too.


Mark Biesiada

Mark Biesiada (view profile)

Contact us