Related vector values via cell array
古いコメントを表示
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 件のコメント
Matt J
2023 年 8 月 12 日
The way you determine that a is related to b is not clear, at least not to me.
Sergio Rojas Blanco
2023 年 8 月 12 日
編集済み: Sergio Rojas Blanco
2023 年 8 月 12 日
Dyuman Joshi
2023 年 8 月 12 日
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
2023 年 8 月 12 日
Dyuman Joshi
2023 年 8 月 12 日
編集済み: Dyuman Joshi
2023 年 8 月 12 日
@Sergio Rojas Blanco, please check my answer.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!