Main Content

Compute the Mean

Compute the mean of a 3-by-2 matrix input, dsp_examples_u, using the Mean block.

Open the model.

model = 'ex_mean_ref';
open_system(model)

In the Mean block, clear the Running mean check box and set the Find the mean value over parameter to Each column. The block processes the input as a two-channel signal with a frame size of three.

Run the model. Display the input and output values.

sim(model)
disp('Data Input')
disp(dsp_examples_u)
disp('Mean Values')
disp(mean_val)
Data Input
     6     1
     1     3
     3     9
    -7     2
     2     4
     5     1
     8     6
     0     2
    -1     5
    -3     0
     2     4
     1    17

Mean Values
    3.3333    4.3333
         0    2.3333
    2.3333    4.3333
         0    7.0000

Under these settings, the block outputs the mean value over each frame of data along both the channels.

Close the model.

close_system(model)

See Also

Blocks