remove the frequent values withou sorting

조회 수: 2 (최근 30일)
huda nawaf
huda nawaf 2022년 7월 10일
댓글: huda nawaf 2022년 7월 11일
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

채택된 답변

the cyclist
the cyclist 2022년 7월 10일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by