Unique value for each sequence of two corresponding variables
1 view (last 30 days)
Show older comments
Hi,
I want to find the unique values for a sequence in A and the value corresponding value in B. For example:
A = [ 1 1 1 2 2 1 1 1 3 3 2 2 2 3 3 3]
B = [ 7 7 7 9 9 7 7 7 7 7 9 9 9 7 7 7]
output
Aa= [1 2 3]
Bb = [7 9 7]
How can I achieve this?
0 Comments
Accepted Answer
Jan
on 26 Sep 2021
A = [ 1 1 1 2 2 1 1 1 3 3 2 2 2 3 3 3];
B = [ 7 7 7 9 9 7 7 7 7 7 9 9 9 7 7 7];
[Aa, iA] = unique(A, 'first');
Bb = B(iA);
Aa
Bb
0 Comments
More Answers (1)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!