Remove repeating variables and replacing them

2 次查看(过去 30 天)
Ex: In the array
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, i want to eliminate all repeating elements and retain non-repeating elements
(4, 5,1,2,3,4,5)
i.e., If
x=[4 4 5 5 1 2 2 3 3 3 4 5]
, answer should be
x=[4 5 1 2 3 4 5]

采纳的回答

Bruno Luong
Bruno Luong 2020-8-22
x = x([true diff(x)~=0])

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by