-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathitCut0.m
More file actions
93 lines (80 loc) · 1.93 KB
/
Copy pathitCut0.m
File metadata and controls
93 lines (80 loc) · 1.93 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function itNew = itCut0(it, tStart, tEnd)
% function itNew = itCut0(it, tStart, tEnd)
%
% Cut the specified interval from the IntensityTier and shift time so that the new tmin = 0
%
% it ... IntensityTier object
% tStart ... [optional] beginning time of interval to be cut (default -Inf = cut from the tMin of the IntensityTier)
% tEnd ... final time of interval to be cut (default Inf = cut to the tMax of the IntensityTier)
%
% v1.0, Tomas Boril, borilt@gmail.com
%
% Example
% it = itRead('demo/maminka.IntensityTier');
% it2 = itCut(it, 0.3);
% it2_0 = itCut0(it, 0.3);
% it3 = itCut(it, 0.2, 0.3);
% it3_0 = itCut0(it, 0.2, 0.3);
% it4 = itCut(it, -Inf, 0.3);
% it4_0 = itCut0(it, -Inf, 0.3);
% it5 = itCut(it, -1, 1);
% it5_0 = itCut0(it, -1, 1);
% subplot(3,1,1)
% itPlot(it)
% subplot(3,1,2)
% itPlot(it2)
% subplot(3,1,3)
% itPlot(it2_0)
% figure
% subplot(2,3,1)
% itPlot(it3)
% subplot(2,3,4)
% itPlot(it3_0)
% subplot(2,3,2)
% itPlot(it4)
% subplot(2,3,5)
% itPlot(it4_0)
% subplot(2,3,3)
% itPlot(it5)
% subplot(2,3,6)
% itPlot(it5_0)
if nargin < 1 || nargin > 3
error('Wrong number of arguments.')
end
if nargin == 1
tStart = -Inf;
tEnd = Inf;
elseif nargin == 2
tEnd = Inf;
end
if isinf(tStart) && tStart>0
error('infinite tStart can be negative only')
end
if isinf(tEnd) && tEnd<0
error('infinite tEnd can be positive only')
end
if isnan(tStart)
error('tStart must be a number')
end
if isnan(tEnd)
error('tEnd must be a number')
end
if tEnd < tStart
error('tEnd must be >= tStart')
end
itNew = it;
itNew.t = it.t(it.t >= tStart & it.t <= tEnd);
itNew.i = it.i(it.t >= tStart & it.t <= tEnd);
if isinf(tStart)
itNew.tmin = it.tmin;
else
itNew.tmin = tStart;
end
if isinf(tEnd)
itNew.tmax = it.tmax;
else
itNew.tmax = tEnd;
end
itNew.t = itNew.t - itNew.tmin;
itNew.tmax = itNew.tmax - itNew.tmin;
itNew.tmin = 0;