Mercurial > repos > public > sbplib
annotate +anim/setup_time_quantity_plot.m @ 69:f87003695677
Moved drawno out of plot update functions for huge performance boost.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 23 Nov 2015 13:54:01 +0100 |
parents | 48b6fb693025 |
children | 243c558dc3ae |
rev | line source |
---|---|
0 | 1 function [update_data, plot_handles] = setup_time_quantity_plot(yfun) |
2 default_arg('yfun',@(y)y); | |
3 | |
69
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
4 if isa(yfun,'function_handle') |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
5 yfun = {yfun}; |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
6 end |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
7 |
0 | 8 t = []; |
9 for i = 1:length(yfun) | |
10 plot_handles(i) = line(0,0); | |
11 plot_handles(i).XData = []; | |
12 plot_handles(i).YData = []; | |
13 quantities{i} = []; | |
14 end | |
15 | |
16 axis_handle = gca; | |
17 legend() | |
18 | |
19 | |
20 function update(t_now,varargin) | |
21 if ishandle(axis_handle) | |
22 t = [t t_now]; | |
23 for j = 1:length(yfun) | |
24 quantities{j} = [quantities{j} yfun{j}(varargin{:})]; | |
25 plot_handles(j).XData = t; | |
26 plot_handles(j).YData = quantities{j}; | |
27 end | |
28 end | |
29 end | |
30 update_data = @update; | |
31 end |