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!