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)) = 1Or 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. Related SolutionsMATLAB: Taking two matrices and outputting as a single number with one matrix being the integer value and one being the decimal value. a = [1 2 3] ;b = [4 5 6] ;iwant = sum(10.^(length(a)-1:-1:0) .* a)+ sum(10.^(length(b)-1:-1:0) .* b)/10^length(b) ; MATLAB: Combine matrix in matlab reshape([A;B],1,[]) Related Question2D interpolation of scattered dataHow to find out the value of a matrix corresponding row and columnHow to automatically split a matrix into multi-Vectors of n variables for combinationHow can i solve
Best Answer