Eliminate or merge the sequences

1 Ansicht (letzte 30 Tage)
Aravin
Aravin am 22 Apr. 2015
Beantwortet: Azzi Abdelmalek am 22 Apr. 2015
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.

Antworten (2)

Kelly Kearney
Kelly Kearney am 22 Apr. 2015
ind = [1 find(diff(v) ~= 0)+1];

Azzi Abdelmalek
Azzi Abdelmalek am 22 Apr. 2015
ind=find(diff([v(1)+1 v]))

Kategorien

Mehr zu Loops and Conditional Statements 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