Mercurial > repos > public > sbplib
comparison +anim/setup_surf_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,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 drawnow | |
| 27 end | |
| 28 end | |
| 29 update_data = @update; | |
| 30 end |
