Combination of X and Y vectors to get all possible positions on a Cartesian plane
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Maximilian Arpaio
el 20 de Mayo de 2019
Respondida: Jos (10584)
el 21 de Mayo de 2019
Dear Community,
I have a challenging task that I am not able to solve so far: I have a vector X of 'n' elements (in my case those are X coordinates) and I have another vector Y of 'm' elements (in my case Y coordinate). I just want to creat a new vector Z with n*m rows and 2 colums that lists within all possible combinations of points on the XY Cartesian plane.
Example:
X=1,2,3,4 (n=4)
Y=5,6 (m=2)
then Z= 1,5 1,6 2,5 2,6 3,5 3,6 and so on....
0 comentarios
Respuesta aceptada
Más respuestas (1)
Jos (10584)
el 21 de Mayo de 2019
For two vectors, x and y, this might be faster than ndgrid (not tested)
xy = [repelem(x(:), numel(y), 1) repmat(y(:), numel(x), 1)]
0 comentarios
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!