MATLAB: Obtaining min value each month across several years

MATLABmatrixminmonthyear

Hi,
I am looking for some help/pointers in how to pull out certain data from a matrix.
My matrix is a note of minimum temperature across each day for a 10 year period.
The matrix is arranged in columns temperature / day / month / year, and starts from 1 July 2000 and runs to 30 June 2010.
I am trying to write instructions to pull out the minimum temperature for each month as well as its row index.
I started trying to just pull the min temp for each month (and worry about row index later) but im alreadty stuck. I am trying to write it using 'for loops' but am open to other methods! I was thinking a for loop would be easier for me to follow.
So far i have got:
load(filename)
len=length(filename)
totalmonth= len/12
mintemp=zeros(totalmonth,1) %i guess will need to put 2 on the end when i get as far as index part
for years= 1990:2000 %so work through the dates
for month=1:12 %then for each year work through each month
mintemp=min(filename(filename(:,3)==month, 1); %may need to build the year check into this and i'm not sure about the '1' returning the data i want in column 1 - i doubt it!
end
I did find a group example on the help forums that would work if i was just after the month but could not work out how to make it also wrap around years as well.
So as you can see i'm good and stuck and would appreciate any help.
Si

Best Answer

G=findgroups(filename(:,3),filename(:,4));
[mintemp,rowIndex]=splitapply(@func,filename(:,1),(1:numel(G)).',G)
function [minT,row]=func(T,R)
[minT,idx]=min(T);
row=R(idx);
end