MATLAB: How to make a list of coordinates out of two lists in Matlab

list of coordinate

Given x = [1,2,3]; y = [4,5,6]; I need to get xy = [(1,4),(2,5),(3,6)];

Best Answer

Use sub2ind:
x = [1,2,3];
y = [4,5,6];
z = zeros(10, 10);
z(sub2ind(size(z), x, y)) = 1
Or a sparse matrix:
x = [1,2,3];
y = [4,5,6];
z = sparse(x, y, 1, 10, 10)
full(z)
Note that according to your example x is the row index and y is the column index. Traditionally, it's the opposite, so I suggest your rename your variables to row and column.