MATLAB: Convert xy Coordinates to Matrix

coordinatesmatrixvector

I have an xy coordinates positions (100×2) and another z vector (100×1) with values corresponding to each xy coordinate. How can I make a matrix of the coordinates with the position of each coordinate having the corresponding z value? Thanks!

Best Answer

after John's comment in Image Analyst's answer:
out = accumarray([x(:),y(:)],z(:),[10 10]);
or
out = zeros(10);
out(sub2ind(size(out),x,y)) = z;