I have a matrix that is a mixture of numbers and NaNs by construction. I looking through answers as to how to use functions like GEOMEAN and MEAN on these type of matrices while ignoring the NaNs in these calculations. I found a response indicating I could use the following structure:
condition=isnan(A)B=geomean(A(~condition))
The "condition" assignment statement works like a charm. In my case it creates an 87×181 logical matrix which is the same dimension as A. However, the statement "A(~condition)" creates a column vector that stacks all my numerical data from A on top of each other instead of preserving the 87×181 structure. This of course completely screws up the GEOMEAN calculation since it returns a single number instead of 181 different numbers.
Appreciate any help,
JK
Best Answer