0
|
1 function [update_data,figure_handle,plot_handles] = setup_1d_plot(x,y_lim,yfun)
|
|
2 default_arg('yfun',{@(y)y});
|
|
3
|
|
4 figure_handle = figure;
|
|
5 plot_handles(1) = plot(x,0*x);
|
|
6 hold on
|
|
7 for i = 2:length(yfun)
|
|
8 plot_handles(i) = plot(x,0*x);
|
|
9 end
|
|
10 hold off
|
|
11
|
|
12 axis_handle = gca;
|
|
13
|
|
14 xlabel('x')
|
|
15 ylabel('y')
|
|
16 xlim([x(1) x(end)]);
|
|
17 ylim(y_lim);
|
|
18
|
|
19 function update(t,varargin)
|
|
20 if ishandle(figure_handle) && ishandle(axis_handle)
|
|
21 for i = 1:length(yfun)
|
|
22 set(plot_handles(i),'YData',yfun{i}(varargin{:}));
|
|
23 end
|
|
24 title(axis_handle,sprintf('T=%.3f',t));
|
|
25 drawnow
|
|
26 end
|
|
27 end
|
|
28 update_data = @update;
|
|
29 end
|