@QUANG_VU_NGUY_N_PH_M wrote:
I firstly declared 2 arrays:
coord1 = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0], [0.0, 2.0], [1.0, 2.0]] coord2 = [[1.0, 0.0], [2.0, 0.0], [1.0, 1.0], [2.0, 1.0]]
I would like to create
- an array
index1
that consists of indice of elements in coord2 that exist in coord1- an array
index2
that consists of indice of elements in coord1 that exist in coord2I create the below code :
index1 = [] index2 = [] for (index, value) in enumerate(coord2) if value in coord1 a = findfirst(x->x==value, coord1) push!(index1, a) push!(index2, index) end end
Is there any better way towards this problem?
Posts: 3
Participants: 2