0
|
1 function [update_data, plot_handles] = setup_time_quantity_plot(yfun)
|
|
2 default_arg('yfun',@(y)y);
|
|
3
|
|
4 t = [];
|
|
5 for i = 1:length(yfun)
|
|
6 plot_handles(i) = line(0,0);
|
|
7 plot_handles(i).XData = [];
|
|
8 plot_handles(i).YData = [];
|
|
9 quantities{i} = [];
|
|
10 end
|
|
11
|
|
12 axis_handle = gca;
|
|
13 legend()
|
|
14
|
|
15
|
|
16 function update(t_now,varargin)
|
|
17 if ishandle(axis_handle)
|
|
18 t = [t t_now];
|
|
19 for j = 1:length(yfun)
|
|
20 quantities{j} = [quantities{j} yfun{j}(varargin{:})];
|
|
21 plot_handles(j).XData = t;
|
|
22 plot_handles(j).YData = quantities{j};
|
|
23 end
|
|
24 drawnow
|
|
25 end
|
|
26 end
|
|
27 update_data = @update;
|
|
28 end
|