HELP ME PLEASE with this geometric mean

how can I make the geometric mean in a matrix of 20x15 with only the positive numbers?

Answers (2)

Bruno Luong
Bruno Luong on 31 Oct 2020
Edited: Bruno Luong on 31 Oct 2020
Assuming A is the vector of your data
geomean = exp(mean(log(A)))
You can do it like this
x = randn(20, 15);
x_positive = x(x>0);
geo_mean = prod(x_positive)^(1/numel(x_positive))

Categories

Asked:

on 31 Oct 2020

Commented:

on 31 Oct 2020

Community Treasure Hunt

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

Start Hunting!