Give this a try:
X=[1950 1; 1950 2; 1950 3; 1951 1; 1951 5; 1952 1];
years = unique(X(:,1));
for ii=1:length(years)
yr_index = find(X == years(ii));
yr_avg(ii) = mean(X(yr_index,2));
end
This will find all the unique year entries. It will then step through each year, find the rows which correspond to the specific year, and take a mean of the second column of just those rows. It will save the mean in the yr_avg vector. Each year entry in the years vector should have a corresponding mean in the yr_avg vector.