Eliminate or merge the sequences

조회 수: 1 (최근 30일)
Aravin
Aravin 2015년 4월 22일
답변: Azzi Abdelmalek 2015년 4월 22일
Hello everyone,
Using vectorization, I want to merge the sequences. Let say I have vector v with values
v = [43 43 43 33 34 35 35 43 43 43 43 43];
I want to get an other vector which should store on only
ind =[1 4 5 6 8];
The sequence should be eleminated and their index should be safed in ind.

답변 (2개)

Kelly Kearney
Kelly Kearney 2015년 4월 22일
ind = [1 find(diff(v) ~= 0)+1];

Azzi Abdelmalek
Azzi Abdelmalek 2015년 4월 22일
ind=find(diff([v(1)+1 v]))

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by