Check if (x,y) point is within 2d array of (x,y) entries. Where x is one column and y another

37 次查看(过去 30 天)
Is there a way to check if (x,y) points is within 2d array of (x,y) entries. Where x is one column and y another. Preferably I want a list of boolean variables with 1 if (x,y) point is present in that positon and zero otherwise

回答(1 个)

Rishabh Mishra
Rishabh Mishra 2020-11-8
Hi,
I would like to point out that to create a matrix of points (x,y) you can use complex number. For example, consider the matrix defined below:
mat = [1+2i 3+i;
3+4i 1+2i];
The above matrix is used to store the cartesian pairs (1,2), (3,1), (3,4) and (1,2).
Let’s say you want check if point 1+2i is present in the matrix or not. You can use the code below:
mat = [1+2i 3+i;
3+4i 1+2i];
point = 1+2i;
check = [mat == point];
Check is Boolean matrix that lists out the positions in original matrix where the point 1+2i is present.
Feel free to revert for any clarifications or queries.
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by