0
|
1 function [update_data,figure_handle] = setup_2d_plot(x,y,z_lim,zfun)
|
|
2 default_arg('zfun',@(z)z);
|
|
3
|
|
4 Z = zeros(length(y),length(x));
|
|
5 figure_handle = figure;
|
|
6 plot_handle = surf(x,y,Z);
|
|
7 plot_handle.LineStyle = 'none';
|
|
8 axis_handle = gca;
|
|
9
|
|
10 xlabel('x')
|
|
11 ylabel('y')
|
|
12 xlim([x(1) x(end)]);
|
|
13 ylim([y(1) y(end)]);
|
|
14 zlim(z_lim);
|
|
15 caxis(z_lim);
|
|
16 % axis vis3d
|
|
17 % colormap(parula(256))
|
|
18 % colorbar
|
|
19
|
|
20 function update(t,z)
|
|
21 Z = zfun(z);
|
|
22 % Z = reshape(zfun(z),length(x),length(y));
|
|
23 if ishandle(plot_handle) && ishandle(axis_handle)
|
|
24 set(plot_handle,'ZData',Z)
|
|
25 title(axis_handle,sprintf('T=%.3f',t));
|
|
26 end
|
|
27 end
|
|
28 update_data = @update;
|
|
29 end
|