MATLAB: How to create a matrix of values from a X and Y coordinates

MATLABmatrix arraymatrix manipulation

Hi
I have a vector u (dots) with its x,y coordinates. Each vector has the same size. I wanto to create a matrix u using x,y coordinates. How I can do it, taking into account that x and y don't form a perfect rectangle.? I mean, there are empty values of u without their coordiantes x,y respectively as you can see in the figure. Empty values can be filled by NaN.
dots.jpg

Best Answer

Thank you everyone for you help.
I all ready solve using the following code.
d = [2.0000 0 0.3800;
2.0000 5.0000 0.3480;
2.0000 25.0000 0.3280;
3.0000 2.0000 0.3190;
3.0000 50.0000 0.2120;
5.0000 10.0000 0.1380;
5.0000 60.0000 0.1100;
5.0000 100.0000 0.0870;
7.0000 5.0000 0.0690;
7.0000 9.0000 0.4113;
7.0000 45.0000 0.3807;
7.0000 95.0000 0.3678;
9.0000 10.0000 0.3207;
9.0000 35.0000 0.1765;
15.0000 65.0000 0.1123;
15.0000 75.0000 0.0917;
15.0000 99.0000 0.0727;
15.0000 125.0000 0.0573;
15.0000 150.0000 0.3811];
X = d(:,1); Y = d(:,2); Z = d(:,3);
Xs = unique(X);
Ys = unique(Y);
Xi = arrayfun( @(x) find(Xs==x), X );
Yi = arrayfun( @(y) find(Ys==y), Y );
Li = Yi + (Xi-1) * numel(Ys);
XYZ = nan(numel(Ys), numel(Xs));
XYZ( Li ) = Z;