comparison +anim/setup_time_quantity_plot.m @ 0:48b6fb693025

Initial commit.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 17 Sep 2015 10:12:50 +0200
parents
children f87003695677
comparison
equal deleted inserted replaced
-1:000000000000 0:48b6fb693025
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