Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How to use the index of a matrix using Unique function to alter a second matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
Say I am looking at 1 row of two matrices
A = [ 2 5 9 3 5 ]
B = [ 1 13 2 8 7]
Using the unique function on A, how would i use the index to rearrange B to match A. Example A1 = B1 , A2 = B2, ...
If i use
[value, indx] = unique(A);
I should get an output of [2 3 5 9] ... how do I apply the index to make B = [ 1, 8, 13, 2] (keeping the matrix values matching)
0 件のコメント
回答 (1 件)
KALYAN ACHARJYA
2019 年 10 月 1 日
編集済み: KALYAN ACHARJYA
2019 年 10 月 1 日
how do I apply the index to make B = [ 1, 8, 13, 2]
>> B=B(indx)
B =
1 8 13 2
Code:
A = [ 2 5 9 3 5 ];
B = [ 1 13 2 8 7];
[value, indx]= unique(A);
B=B(indx)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!