1 function p = comsol_plot_sequence(varargin)
2 %
function p = comsol_plot_sequence(varargin)
4 % This
function was mainly copied from
plot_sequence and adopted to special
5 % COMSOL usage. So please see the explanation there...
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 %
function p =
plot_sequence(sim_data,params[,callbackfigure, cbhandle])
12 % plotting a sequence of data slices on polygonal
13 % 2d grid (constructed from params
if empty) and providing a slider
14 %
for changing between the data
17 % A
new figure is opened and the handle returned in p. If further parameters
18 % are set, the call is assumed to stem from a callback-
function
20 % Every column of data is interpreted as one discrete
function
21 % dof vector forwarded to the params.plot()
function.
24 % varargin: usually called with 3 arguments:
26 % - data - data vector to be plotted
27 % - grid - the underlying grid
28 % - params - plotting parameters
30 % Alternatively, there can be 5 arguments:
31 % @code plot_sequence(data, grid, params, callbackfigure, cbhandle) @endcode
32 % This function is set as a callback function for the time slider
33 % uicontrol. The additional arguments are:
34 % - callbackfigure - handle to the figure
35 % - cbhandle - handle to the object calling the callback function. This
36 % is usually the time slider.
39 % p : figure handle of plot
41 % required fields in params:
42 % - 'plot' -- pointer to the plot-function performing the plotting of a
43 % single slice, e.g. plot_element_data(), plot_vertex_data(),
44 % fv_plot(), ldg_plot().
46 % optional field of params:
47 % - 'title' -- string indicating the title of the newly opened figure
48 % - 'clim' -- 2-vector giving the range of the colormap. If this is set,
49 % identical range is used for all slices. Default is the min and
51 % - 'clim_tight' -- if this flag is set, the colorbar is set tightly to the
52 % range of every single data slice. Clearly only one of
53 % 'clim' or 'clim_tight' should be set.
55 % see also the chosen 'params.plot_function' for its further params-options
57 % Bernard Haasdonk 9.5.2007
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 if nargin < 3 % no callback, open new figure
74 txt = uicontrol(f,
'Style',
'text',
'Units',
'normalized',...
75 'Position',[di,di,textwidth,textheight],...
76 'String',
'Slice 1',
'Tag',
'text1');
77 slider = uicontrol(f,
'Style',
'slider',
'Units',
'normalized',...
78 'Position',[di+textwidth+di, di ,1-3*di-textwidth,...
79 textheight],
'Tag',
'slider1',...
80 'Callback',
'comsol_plot_sequence([],[],gcbf,gcbo)');
81 ax = axes(
'Units',
'normalized',...
82 'Position',[di,2*di+textheight,1-2*di,1-3*di - textheight],...
86 ud.sim_data = varargin{1};
87 ud.params = varargin{2};
91 sl = findobj(f,
'Tag',
'slider1');
93 %set(sl,
'max',ud.params.nt);
94 %set(sl,
'sliderstep',[1/ud.params.nt,1]);
96 if size(ud.sim_data.U,2)>1
97 set(sl,
'max',size(ud.sim_data.U,2));
98 set(sl,
'sliderstep',[1/(size(ud.sim_data.U,2)-1),1]);
100 set(sl,
'max',size(ud.sim_data.U,2)+eps);
101 set(sl,
'visible',
'off');
102 % set(sl,
'sliderstep',[0,0]);
105 th = findobj(f,
'Tag',
'text1');
106 set(th,
'String',(
'data slice 1') );
108 % set(f,
'Resize',
'on');
112 if nargin >=3 % callback-function
115 th = findobj(gcbf,
'Tag',
'text1');
116 v = round(
get(gcbo,
'value'));
118 set(th,'String',['data slice ',num2str(v)]);
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124 function replot(fh,oh,v)
125 ud = get(fh,'Userdata');
128 ud.sim_data.comsol_model.result('pg1').set('solnum',v);
130 ax = findobj(fh,'Tag','axes1');
133 mphplot(ud.sim_data.comsol_model,'pg1','rangenum',1)
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...