comparison +anim/setup_time_quantity_plot.m @ 72:942cb3c53a47

Simplified implementation of time quantity plot.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 23 Nov 2015 14:55:58 +0100
parents 243c558dc3ae
children d0df12c03aac
comparison
equal deleted inserted replaced
71:1edee9e1ea41 72:942cb3c53a47
5 yfun = {yfun}; 5 yfun = {yfun};
6 end 6 end
7 7
8 t = []; 8 t = [];
9 for i = 1:length(yfun) 9 for i = 1:length(yfun)
10 plot_handles(i) = line(0,0); 10 plot_handles(i) = animatedline();
11 plot_handles(i).XData = [];
12 plot_handles(i).YData = [];
13 quantities{i} = [];
14 end 11 end
15 12
16 axis_handle = gca; 13 axis_handle = gca;
17 legend() 14 legend()
18 15
19 16
20 function update(t_now,varargin) 17 function update(t_now,varargin)
21 if ishandle(axis_handle) 18 if ishandle(axis_handle)
22 t = [t t_now]; 19 % t = [t t_now];
23 for j = 1:length(yfun) 20 for j = 1:length(yfun)
24 quantities{j} = [quantities{j} yfun{j}(varargin{:})]; 21 addpoints(plot_handles(j),t_now,yfun{j}(varargin{:}));
25 plot_handles(j).XData = t;
26 plot_handles(j).YData = quantities{j};
27 end 22 end
28 23
29 if t(end) > t(1) 24 [t,~] = getpoints(plot_handles(1));
30 xlim([t(1) 1.1*t(end)]); 25 if t(1) < t(end)
26 xlim([t(1) t(end)]);
31 end 27 end
32 end 28 end
33 end 29 end
34 update_data = @update; 30 update_data = @update;
35 end 31 end