MATLAB: How to extract unique values associated with repeated values in another column

for loop

I have monthly climate data, and I've copied a subset below. The first column has values that repeat from 1 to 12 (months), and the second column has unique precipitation values. How do I extract the ppt values for each individual month and put in a separate vector? For example, how do I extract the ppt values associated with value 1, and then create a separate vector. With the dataset below, the new vector would only have two rows, since the monthly value of 1 only repeats twice. My full dataset has 122 repetitions. I would like to write a forloop for this.
month ppt
1.0000 344.6000
2.0000 92.1900
3.0000 170.0400
4.0000 32.8000
5.0000 30.0400
6.0000 0
7.0000 0
8.0000 0
9.0000 10.6500
10.0000 12.5400
11.0000 43.0900
12.0000 38.7300
1.0000 297.5600
2.0000 13.1100
3.0000 168.8700
4.0000 87.6600
5.0000 51.0700
6.0000 0
7.0000 1.0900
8.0000 6.7100
9.0000 6.2600
10.0000 50.9100
11.0000 109.7800
12.0000 93.0600

Best Answer

mp = [
1.0000 344.6000
2.0000 92.1900
3.0000 170.0400
4.0000 32.8000
5.0000 30.0400
6.0000 0
7.0000 0
8.0000 0
9.0000 10.6500
10.0000 12.5400
11.0000 43.0900
12.0000 38.7300
1.0000 297.5600
2.0000 13.1100
3.0000 168.8700
4.0000 87.6600
5.0000 51.0700
6.0000 0
7.0000 1.0900
8.0000 6.7100
9.0000 6.2600
10.0000 50.9100
11.0000 109.7800
12.0000 93.0600];
month = mp(:,1);
ppt = mp(:,2);
results = accumarray(month, ppt, [12 1], @(V) {V.'});
In the special case where each month has the same number of entries, you can then proceed to
vertcat(results{:})