-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlplot.m
executable file
·43 lines (33 loc) · 1009 Bytes
/
lplot.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
% lplot(VEC, XRANGE)
%
% Plot VEC, a vector, in "lollipop" format.
% XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector
% specifying the X positions (for labeling purposes) of the first and
% last sample of VEC.
% Mark Liberman, Linguistics Dept, UPenn, 1994.
function lplot(x,xrange)
if (exist('xrange') ~= 1)
xrange = [1,length(x)];
end
msize = size(x);
if ( msize(2) == 1)
x = x';
elseif (msize(1) ~= 1)
error('First arg must be a vector');
end
if (~isreal(x))
fprintf(1,'Warning: Imaginary part of signal ignored\n');
x = abs(x);
end
N = length(x);
index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1);
xinc = index(2)-index(1);
xx = [zeros(1,N);x;zeros(1,N)];
indexis = [index;index;index];
xdiscrete = [0 xx(:)' 0];
idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc];
[mn,mx] = range2(xdiscrete);
ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding
plot(idiscrete, xdiscrete, index, x, 'o');
axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]);
return