Sorting group position from 1

1 view (last 30 days)
Abhineet Prakash
Abhineet Prakash on 28 Nov 2022
Answered: Jonas on 28 Nov 2022
I have a group number of array
1) [2 3 2 1] I want [1 2 1 3]
2) [3 3 1 2] I want [1 1 2 3]

Accepted Answer

Jonas
Jonas on 28 Nov 2022
i think you are searching for this:
[~,~,c]=unique([2 3 2 1],'stable')
c = 4×1
1 2 1 3
[~,~,c]=unique([3 3 1 2],'stable')
c = 4×1
1 1 2 3

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!