Avg over a 3d array?

Hi there!
So I have monthly gridded datasets in lat/lon/time(monthly): Example:
>> whos KoppenD_airT
Name Size Bytes Class Attributes
KoppenD_airT 360x720x361 374284800 single
>> whos KoppenDsa_airT
Name Size Bytes Class Attributes
KoppenDsa_airT 360x720x361 374284800 single
>> whos KoppenDsb_airT
Name Size Bytes Class Attributes
KoppenDsb_airT 360x720x361 374284800 single
I need to create climatologies of these regions so that I can plot monthly changes in temperature over my 30 year climate period. What is the best way to do this?
I need to aggregate my monthly data over the entire region to a single value so that I can plot all of my months.
Here's one attempt I've made that isn't working:
idx=find(Dsa);
for ii=idx
y=ind2sub(size(KoppenDsa_airT),ii);
x=squeeze(KoppenDsa_airT(y,:));
end
I get:
Index exceeds matrix dimensions.
Thanks!

 Akzeptierte Antwort

Matt J
Matt J am 12 Jul. 2013
Bearbeitet: Matt J am 12 Jul. 2013

1 Stimme

aggregate my monthly data over the entire region to a single value
Does "aggregate" mean average? If so, this might be what you want,
mean(reshape(KoppenDsa_airT,[],361),1);

4 Kommentare

Kate
Kate am 12 Jul. 2013
Wait, question: Now my values are ranging between -1 and 1. Is the above code referencing the 1 dimension of the array instead of the 3rd?
Matt J
Matt J am 12 Jul. 2013
It should be averaging over each KoppenDsa_airT(:,:,i)
Kate
Kate am 12 Jul. 2013
I realized my problem, I have a mask on my data so that non Koppen Dsa's are zero, I need to turn those into NaN's, thanks again for your help!
Matt J
Matt J am 12 Jul. 2013
If you turn them into NaNs, you would probably have to use nanmean()

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Climate Science and Analysis finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 12 Jul. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by