MATLAB: Reshaping an array of n rows in a custom way

MATLABrearranging arrays

I have an output file (txt) from a software that appears in the following form (nx2 array).
1 4.5
1 5
1 6.4
2 7
2 3.5
2 4
3 2
3 1.1
3 9
In order to use this data in another software, i want to rearrange the array in the form (nx4) so that i can get an outputfile that has the data in the following form.
1 4.5 5 6.4
2 7 3.5 4
3 2 1.1 9
I would appreciate if someone can guide me to get the data in the desired format.

Best Answer

B = [unique(A(:,1)) reshape(A(:,2)',[],3)']