-
Notifications
You must be signed in to change notification settings - Fork 1
/
plotBarcode.m
42 lines (31 loc) · 890 Bytes
/
plotBarcode.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
37
38
39
40
41
42
function h = plotBarcode( barcode )
% PLOTBARCODE Plots a barcode.
% h = plotBarcode( barcode )
%
% Input:
%
% barcode - an N x 2 matrix of start/stop values representing each
% bar
%
% Output:
% h - vector line objects representing each line in the bar plot.
%
% To change all colors to be the same, run, e.g.,
%
% [h.Color] = deal( 'r' ); % make them all red.
%
% or to make them all thicker
% [h.LineWidth] = deal( 2 );
arguments
barcode (:,:) {mustBeNonempty}
end
% barcodes with infinite duration
isPersistent = isinf(barcode(:,2));
% set the "inf" values to twice the max;
barcode(isPersistent, 2) = 2*max( barcode(~isPersistent,2) );
h = plot( barcode.', repmat(1:size(barcode,1), 2,1) );
% set the color of the first to all
[h.Color] = deal(h(1).Color);
[h(isPersistent).Color] = deal('r');
[h(isPersistent).LineWidth] = deal(2);
end