Calculating GeoMean of a double array

6 Ansichten (letzte 30 Tage)
iceskating911
iceskating911 am 1 Jul. 2022
Kommentiert: iceskating911 am 1 Jul. 2022
Hi! I'm still learning MATLAB and have a question about calculating the geometric mean.
Right now, I have a long forloop that is looping for 10 iterations. I have a 1x16 double array that is the result of the first part of my forloop and looks something like this:
It is a 1x16 double array with a summed value in each array spot.
Now I want to take the geometric mean of each column in the same forloop to get another 1x16 double array with one value in each column.
So far, the part for that, looks like this:
a = SimData(:,78);
b = SimData(:,80);
for ii = 1 : length(edges)-1
indexes = a > edges(ii) & a <= edges(ii+1);
binByBinSums(ii) = sum(b(indexes)); %Summed value that creates the 1x16 double
boot_mean(i)=geomean(binByBinSums); %Geometric mean for each ieration of binByBinSums
end
However currently this code gives me boot_mean as taking the geometric mean across the board, 10 times, as shown below:
How do I go about calculating the geometric mean of one column in a double? Any help is very appreciated, thank you!

Akzeptierte Antwort

GeeTwo
GeeTwo am 1 Jul. 2022
% Here's some data for a sample
A=magic(4)
A = 4×4
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
% And here we'll calculate the geometric mean of each column
vect=prod(A,1).^(1/size(A,1))
vect = 1×4
7.3257 6.8142 7.2084 5.9437
  1 Kommentar
iceskating911
iceskating911 am 1 Jul. 2022
Ah! Makes perfect sense, wasn't sure if i was using the function geomean right in this way so thank you so much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Scan Parameter Ranges finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by