-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddWin.m
63 lines (59 loc) · 1.51 KB
/
addWin.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function addWin(H,gram,x,y)
if isempty(H)
H = gca;
else
axes(H)
end
if ~exist('x','var'); x = []; end
if ~exist('y','var'); y = []; end
hold on
% winSz = gram.lWin;
Fs = gram.param.Fs;
winSz = gram.win(1) + 0.5/Fs;
if contains(H.Title.String,'timeseries')
if size(gram.t,2)>1
y = ylim;
xx = gram.t(:,:,:,:,:,:,1);
yy = repmat(y(1),[size(xx,1) 1]);
line(xx,yy,'Color','m','linewidth',3)
xx = gram.t(:,:,:,:,:,:,end);
yy = repmat(y(2),[size(xx,1) 1]);
line(xx,yy,'Color','m','linewidth',3)
else
yLim = ylim;
xLim = xlim;
if isempty(x)
x = xLim(1); x = x.*[1 1];
xx = x + [0 1].*winSz;
else
x = x.*[1 1];
xx = x + [-0.5 0.5].*winSz;
end
if isempty(y) || y==-inf
y = yLim(1);
elseif y==inf
y = yLim(2);
end
y = y.*[1 1];
line(xx,y,'Color','m','linewidth',3)
end
elseif contains(H.Title.String,'spectrogram') || contains(H.Title.String,'coherogram')
im = findobj(H.Children,'type','image');
if isempty(x)
x = im.XData(1) - mean(diff(im.XData))/2;
x = x .* [1 1];
xx = x + [0 1].*winSz;
else
x = x .* [1 1];
xx = x + [-0.5 0.5].*winSz;
end
if isempty(y)
y = im.YData(end) + mean(diff(im.YData))/2;
else
dbstack; error('code that');
end
y = y .* [1 1];
line(xx,y,'color','m','linewidth',3);
else
dbstack; error('code that')
end