-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtgGetIntervalDuration.m
More file actions
35 lines (28 loc) · 890 Bytes
/
Copy pathtgGetIntervalDuration.m
File metadata and controls
35 lines (28 loc) · 890 Bytes
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
function t = tgGetIntervalDuration(tg, tierInd, index)
% function t = tgGetIntervalDurationTime(tg, tierInd, index)
%
% Return duration (i.e., end - start time) of interval in interval tier.
%
% tierInd ... tier index or 'name'
% index ... index of interval
%
% v1.0, Tomas Boril, borilt@gmail.com
%
% Example
% tg = tgRead('demo/H.TextGrid');
% tgGetIntervalDuration(tg, 'phone', 5)
if nargin ~= 3
error('Wrong number of arguments.')
end
tierInd = tgI(tg, tierInd);
if ~tgIsIntervalTier(tg, tierInd)
error(['tier ' num2str(tierInd) ' is not IntervalTier']);
end
if ~isInt(index)
error(['index must be integer >= 1 [' num2str(index) ']']);
end
nint = tgGetNumberOfIntervals(tg, tierInd);
if index < 1 || index>nint
error(['index out of range, index = ' num2str(index) ', nint = ' num2str(nint)]);
end
t = tg.tier{tierInd}.T2(index) - tg.tier{tierInd}.T1(index);