Related vector values via cell array
Afficher commentaires plus anciens
Hi guys, I hope someone can help me:
I have a vector. Suppose this:
A=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)'
Some values of this vector are related through a cell array, in such a way that a value of the vector is the index of a cell. I need to know if a value of the vector "a" is related to another value "b".
B={15, 12, 0, [11, 7], 9, 0, [1, 20, 21], 18, 7, 0, 16, [13, 14], 17, 4, 6};
a=2; b=7
In this case, 2 and 7 are related:
Index Value
2 12
12 13,14
13 17
17 Nan
14 4
4 7
So, a=5 and b=6; and a=4 and b=1 are also related.
Thanks to the whole community
5 commentaires
Matt J
le 12 Août 2023
The way you determine that a is related to b is not clear, at least not to me.
Sergio Rojas Blanco
le 12 Août 2023
Modifié(e) : Sergio Rojas Blanco
le 12 Août 2023
Dyuman Joshi
le 12 Août 2023
By this logic, a=4 and b=1 are related.
B={15, 12, 0, [11, 7], 9, 0, [1, 20, 21], 18, 7, 0, 16, [13, 14], 17, 4, 6};
Idx 4 - 11
Idx 11 - 16
Idx 16 - NaN
Idx 4 - 7
Idx 7 - 1
Related.
Sergio Rojas Blanco
le 12 Août 2023
Dyuman Joshi
le 12 Août 2023
Modifié(e) : Dyuman Joshi
le 12 Août 2023
@Sergio Rojas Blanco, please check my answer.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!