-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlivePlot.m
More file actions
83 lines (65 loc) · 1.83 KB
/
livePlot.m
File metadata and controls
83 lines (65 loc) · 1.83 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
function livePlot( t, x, y, z )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Author: Marshall Herr
%%%
%%% Purpose: Takes in x,y,z data and a time vector and plots the x,y,z
%%% points in real time
%%%
%%% Inputs:
%%% - t: Time vector
%%% - x: X position vector
%%% - y: Y position vector
%%% - z: Z position vector
%%%
%%% Date Created: 21 Feb 2019
%%% Last Editted: 21 Feb 2019
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global pace;
pace = 1;
buttonWidth = 0.1;
buttonHeight = 0.05;
f = figure();
a = axes( 'Parent', f );
colormap(fliplr(jet))
% Add pushbutton to view data
stopButton = uicontrol( 'Parent', f, 'Style', 'pushbutton', ...
'String', 'Pause', 'Units', 'normalized', ...
'Position', [0.99 - buttonWidth, 0.01, buttonWidth, buttonHeight], ...
'Callback', @stopButtonPressed, 'Visible', 'on' );
colors = jet(length(t));
angles = [ 45, 45 ];
i = 1;
tic;
pauseTime = 0;
while ishandle(f) && ( i <= length(t) )
scatter3( x(1:i), y(1:i), z(1:i), 1, colors(end:-1:end-i+1,:) )
title( [ 'Current Time: ', num2str( floor( t(i)/60 ) ), ':', ...
num2str( t(i) - 60*floor( t(i)/60 ) ) ] )
xlabel('East [m]')
ylabel('North [m]')
zlabel('Zenith [m]')
c = colorbar( 'EastOutside' );
c.Label.String = 'Time [s]';
caxis( [ min(t), max(t) ] );
view( angles )
daspect([1,1,1]);
pbaspect([1,1,1]);
drawnow;
while ~pace && ishandle(f)
angles = get( a, 'View' );
pause(0.01);
pauseTime = toc - t(i);
end
[ ~, i ] = min( abs( t - toc + pauseTime ) );
end
end
function stopButtonPressed(scr,event)
global pace;
if strcmpi( scr.String, 'pause' )
scr.String = 'Continue';
pace = 0;
else
scr.String = 'Pause';
pace = 1;
end
end