MATLAB: How to rearrange this dataset

contourmatricessortvector

Hello,
I would like to make a contour plot (i.e., contourf(x,y,z)), where x is year-day, y is depth, and z is data). However, the shape of my dataset currently looks like:
x y z
21 0 0.1
21 10 0.23
21 20 0.32
22 0 0.31
22 10 0.14
22 20 0.42
23 0 0.23
23 10 0.43
23 20 0.38
I understand that to make a contour plot, z should be looking like this:
0.1 0.31 0.23
0.23 0.14 0.43
0.32 0.42 0.38
How to arrange data like above one? Or is there any other way to make a contour plot with what I have?
Thanks

Best Answer

There may have been slicker ways to do this further "upstream" in your code, but now you could just do
>> z = reshape(z,3,3);