How do I get index matrix for matrix of values?
2 views (last 30 days)
Show older comments
hi, can anyone one help me
if i have matrix A i want get index matrix for matrix A
A=[9 5 1
6 5 7
8 4 11]
for exmple The result
A_index =11 12 13
21 22 23
31 32 33
4 Comments
Fangjun Jiang
on 5 Mar 2021
Edited: Fangjun Jiang
on 5 Mar 2021
It looks like
Row 1 Column 1, Row 1 Column 2, Row 1 Column 3
Row 2 Column 1, Row 2 Column 2, Row 2 Column 3
I don't know what is the meaning, purpose or usefulnesss for this
Accepted Answer
Cris LaPierre
on 5 Mar 2021
Edited: Cris LaPierre
on 5 Mar 2021
Now I'm confused, too. You've now posted two completely different types of index matrices. Perhaps instead, could you explain how A maps to A_index?
A_index =11 12 13
21 22 23
31 32 33
As for the current A_index, you can take advantage of implicit expansion to create it.
A_index = (10:10:30)' + (1:3)
More Answers (1)
Fangjun Jiang
on 5 Mar 2021
Edited: Fangjun Jiang
on 5 Mar 2021
>> [Row,Column]=ind2sub([3,3],1:9)
Row =
1 2 3 1 2 3 1 2 3
Column =
1 1 1 2 2 2 3 3 3
>> [Row,Column]=ind2sub([11,11],[10,11,12, 109,110,111])
Row =
10 11 1 10 11 1
Column =
1 1 2 10 10 11
0 Comments
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!