Filter löschen
Filter löschen

Identify missing section's boundaries in an index

1 Ansicht (letzte 30 Tage)
paco
paco am 16 Mär. 2017
Beantwortet: Greg Dionne am 16 Mär. 2017
dear matlab community, I started working with matlab about a month ago so I am still a beginner and this question might (I hope) have a very easy solution.
I working on large arrays (2000000 points) and for an analysis I am extracting only specific parts of it. When I extract the data I want to work with I get an vector of the indexes of the point I need, something like:
index=[1,2,...,412,413,1265,1266,...,2874,2875,9654,9655,...]
and I want to get something like: B={[413 1265][2875 9655]} or any way to identify both ends of the missing part.
so far i have tried to use diff but it doesnt return the upper limit and the whole thing isn't really working! I hope that you can understand what I want to do and find a solution. I'm adding here things I've been trying but it not an actual script just bits of it...
index_b=find(data_v < (-0.06)); %condition
k_b=time_v(find(diff(index_b) > 1))'; %get lower index
A_b = cell(1, length(k_b)+1); %prealloc
for i = 1:length(k_b)
A_b{i} = index_b(count_b+1:k_b(i)); %creat cell array
count_b=k_b(i);
end
t_b=[];
for i= 1:length(A_b); %merge the cells
t_b=[t_b,A_b{i}];
end
time_b=time(t_b);

Antworten (1)

Greg Dionne
Greg Dionne am 16 Mär. 2017
Do you just want all the elements less than -0.06?
Then
data_v(data_v < -0.06)
should give you want you want.
If you need a single range you can do:
data(istart:istop)

Kategorien

Mehr zu Matrix Indexing 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