필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to remove repeated values mantaining the first one from an array ?

조회 수: 1 (최근 30일)
Andre
Andre 2014년 12월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
I have something like:
10000111111111011011100000111011000111111011000000010101011111111....
how to:
00000100000000010010000000100010000100000010000000000000010000000....
The second repetition makes the beggining of a series.

답변 (2개)

Sean de Wolski
Sean de Wolski 2014년 12월 8일
abs(diff('0000111001111101101'))
  댓글 수: 1
Guillaume
Guillaume 2014년 12월 8일
Hum, it looks like the OP only wants the transitions from 0 to 1 (which would be diff(x) > 0) but only when there's more than one consecutive 1 (which is not as simple unfortunately).

Guillaume
Guillaume 2014년 12월 8일
s = '10000111111111011011100000111011000111111011000000010101011111111'
o = char('0' + ([0 diff(s) > 0] & [~diff(s) 0]))

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by