remove the frequent values withou sorting

2 Ansichten (letzte 30 Tage)
huda nawaf
huda nawaf am 10 Jul. 2022
Kommentiert: huda nawaf am 11 Jul. 2022
hello
I need a function remove the frequent values(keeping the first appearance of value) without using unique because it is making sortg
For example
x=[3 4 3 5 1 0 4 2];
I need x to be
x=[3 4 5 1 0 2]
Thanks in advance

Akzeptierte Antwort

the cyclist
the cyclist am 10 Jul. 2022
You can still use unique:
x = [3 4 3 5 1 0 4 2];
x = unique(x,"stable")
x = 1×6
3 4 5 1 0 2

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by