From: "David " <>
Newsgroups: comp.soft-sys.matlab
Subject: Help averaging multidimensional array
Date: Mon, 20 Feb 2012 15:09:12 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <jhtnmo$ge3$>
Reply-To: "David " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1329750552 16835 (20 Feb 2012 15:09:12 GMT)
NNTP-Posting-Date: Mon, 20 Feb 2012 15:09:12 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3336373
Xref: comp.soft-sys.matlab:758228


I have a multidimensional array:

gulf  60x90x456

60 and 90 refer to longitude and latitude, 456 is months. each long/lat point has a different value at each month: eg.

gulf(24,53,1) = -84.7

I need to average these values to 10 degree boxes; so the new dataset will become:

new 6x9x456

Obviously using the basic mean function doesnt work as this only produces means of each column therefor mean2 would be needed however the dataset includes many NaN values and mean2 does not account for this and as far as I am aware there is no nanmean equivalent for mean2.
I assume a for-loop would be the most sensible way of doing this but everything I have tried doesn't seem to work.

Any help would be hugely appreciated as this is very important!