Imagine the following array:

a = [10768,10764,10893,10763,10723,10792,0,0,0,0]

Using a function like "MEAN" in IDL, is there a way to calculate the mean value, ignoring the zeros? I know this can easily be done in a for-loop, but I would prefer a ready made function for the sake of simplicity and performance.

closed as off-topic by Mark Ireland, Vince, mkennedy, Andre Silva, LaughU Jan 14 at 10:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general IT or with no clear GIS component, are off-topic here but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software), Database Administrators (relational databases) and other SE sites" – Mark Ireland, Vince, mkennedy, Andre Silva, LaughU
If this question can be reworded to fit the rules in the help center, please edit the question.


You can always make a selection of the valid items:

a[WHERE(a NE 0)]

Not the answer you're looking for? Browse other questions tagged or ask your own question.