Use mat2cell as the engine. I assume that you want to aggregate the results of the second column of your patient profile array, as a function of the first column. If the profile is in an array called PP:
counts = [6;4;10];
C = mat2cell(PP(:,2),counts)
C =
[ 6x1 double]
[ 4x1 double]
[10x1 double]
See that this step has done the job of extracting the data into separate cells.
C{:}
ans =
2
3
-2
1
3
2
ans =
-1
-3
0
-2
ans =
2
2
1
3
2
-1
-2
-3
-2
-2
If PP was not sorted in advance, we would have needed to sort on the first column of PP. So all that we need to do is to know how many entries corresponded to each patient. That is a task that accumarray can handle.
counts = accumarray(PP(:,1),1)
counts =
6
4
10
Finally, had the list of patient identifiers been more sophisticated than the numbers (1:3), a call to unique would have resolved that problem for you.