0
|
1 function [update_data,figure_handle] = setup_2d_plot(x,y,clim,zfun)
|
|
2 default_arg('zfun',@(z)z);
|
|
3
|
|
4 Z = zeros(length(x),length(y));
|
|
5 figure_handle = figure;
|
|
6 plot_handle = imagesc(x,y,Z);
|
|
7 axis_handle = gca;
|
|
8
|
|
9 xlabel('x')
|
|
10 ylabel('y')
|
|
11 xlim([x(1) x(end)]);
|
|
12 ylim([y(1) y(end)]);
|
|
13 caxis(clim);
|
|
14 % axis vis3d
|
|
15 colormap(parula(256))
|
|
16 colorbar
|
|
17
|
|
18 function update(t,z)
|
|
19 Z = zfun(z);
|
|
20 % Z = reshape(zfun(z),length(x),length(y));
|
|
21 if ishandle(plot_handle) && ishandle(axis_handle)
|
|
22 set(plot_handle,'CData',Z)
|
|
23 title(axis_handle,sprintf('T=%.3f',t));
|
|
24 end
|
|
25 end
|
|
26 update_data = @update;
|
|
27 end
|
|
28
|
|
29
|
|
30 % TODO
|
|
31 % This function is for squre grid.
|
|
32 % This function is for 2d image.
|
|
33 % Make one for 3d surface
|
|
34 % Make one for curvilinear grids using pcolor
|
|
35
|
|
36
|
|
37 function [update_data,figure_handle,plot_handles] = setup_1d_plot(x,y_lim,yfun)
|
|
38
|
|
39 figure_handle = figure;
|
|
40 plot_handles(1) = plot(x,0*x);
|
|
41 hold on
|
|
42 for i = 2:length(yfun)
|
|
43 plot_handles(i) = plot(x,0*x);
|
|
44 end
|
|
45 hold off
|
|
46
|
|
47 axis_handle = gca;
|
|
48
|
|
49 xlabel('x')
|
|
50 ylabel('y')
|
|
51 xlim([x(1) x(end)]);
|
|
52 ylim(y_lim);
|
|
53
|
|
54 function update(t,varargin)
|
|
55 if ishandle(figure_handle) && ishandle(axis_handle)
|
|
56 for i = 1:length(yfun)
|
|
57 set(plot_handles(i),'YData',yfun{i}(varargin{:}));
|
|
58 end
|
|
59 title(axis_handle,sprintf('T=%.3f',t));
|
|
60 drawnow
|
|
61 end
|
|
62 end
|
|
63 update_data = @update;
|
|
64 end
|
|
65
|
|
66
|
|
67
|