-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtgRemovePoint.m
More file actions
43 lines (35 loc) · 1.08 KB
/
Copy pathtgRemovePoint.m
File metadata and controls
43 lines (35 loc) · 1.08 KB
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
43
function tgNew = tgRemovePoint(tg, tierInd, index)
% function tgNew = tgRemovePoint(tg, tierInd, index)
%
% Remove point of the given index from the point tier.
%
% tierInd ... tier index or 'name'
%
% v1.0, Tomas Boril, borilt@gmail.com
%
% Example
% tg = tgRead('demo/H.TextGrid');
% tg.tier{tgI(tg, 'phoneme')}.Label .'
% tg2 = tgRemovePoint(tg, 'phoneme', 1);
% tg2.tier{tgI(tg2, 'phoneme')}.Label .'
if nargin ~= 3
error('Wrong number of arguments.')
end
tierInd = tgI(tg, tierInd);
if ~tgIsPointTier(tg, tierInd)
error(['tier ' num2str(tierInd) ' is not PointTier']);
end
npoints = tgGetNumberOfPoints(tg, tierInd);
if index < 1 || index>npoints
error(['index of point out of range, index = ' num2str(index) ', npoints = ' num2str(npoints)]);
end
if ~isInt(index)
error(['index must be integer >= 1 [' num2str(index) ']']);
end
tgNew = tg;
for I = index: npoints - 1
tgNew.tier{tierInd}.T(I) = tgNew.tier{tierInd}.T(I+1);
tgNew.tier{tierInd}.Label{I} = tgNew.tier{tierInd}.Label{I+1};
end
tgNew.tier{tierInd}.T(end) = [];
tgNew.tier{tierInd}.Label(end) = [];