I have three matrix like these:
categories1 =
1 2 NaN
3 NaN NaN
4 NaN NaN
categories2 =
1 2 3 NaN
4 5 6 NaN
4 5 6 7
that put beside give:
all_categories =
1 2 NaN 1 2 3 NaN
3 NaN NaN 4 5 6 NaN
4 NaN NaN 4 5 6 7
Then, I have two vectors like:
obj1 = [4 2 1]
obj2 = [2 3 5]
How can I establish a condition that permits a certain operation between an element of obj1
and one of obj2
, if and only if their correspondent category belong to the same line in all_categories? In other words, I would like to start a if block in the form:
if (a specified element of array `obj1` is on the same line of another specified element of the array`obj2`)
do something
end
For instance, the condition would be verified in case of obj1(2)
and obj2(1)
, because their correspondent value are both on the 1st line of all_categories
).
Basically, I am trying to implement the condition that only if there is compatibility between and object belonging to a certain category and another object belonging to another category than an operation can happen. Hope this has not been too long to explain. Many thanks.
Aucun commentaire:
Enregistrer un commentaire