-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_where_broken.m
executable file
·36 lines (27 loc) · 1.01 KB
/
find_where_broken.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [ broken_track, breaking_event ] = find_where_broken ( SoE_statemat_in )
% Input: statemat. Find a place where states become <= 0
% should be the track where it happens _last_
% [ frame#, 1/2=birth/death, THIS track # , othertrack split/merge with ]
[ Nevents , Nsubtracks ] = size( SoE_statemat_in );
breaking_event = Nevents+1;
% scan through each track looking for untenables
for Tri = 1:Nsubtracks
% get the indices of non-positive numeric state values for this track
Trseq = SoE_statemat_in(:, Tri);
unten = find ( Trseq < 1 );
% if any occur:
if ( length(unten) >= 1 )
% then take the first such index
unten_onset = min( unten );
% and if it occurs later than the current last one,
% set it as our breaking event.
if ( unten_onset < breaking_event )
breaking_event = unten_onset;
broken_track = Tri;
end
end
end
if ( breaking_event <= 0 )
disp("ERROR in find_where_broken. Did not find anything broken.")
end
end