KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FunVis2D.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function varargout = FunVis2D(varargin) {
18 
19 
20 /* FunVis2D, by itself, creates a new FunVis2D or raises the existing
21  * singleton*.
22  *
23  * H = FunVis2D returns the handle to a new FunVis2D or the handle to
24  * the existing singleton*.
25  *
26  * FunVis2D('CALLBACK',hObject,eventData,handles,...) calls the local
27  * function named CALLBACK in FunVis2D.M with the given input arguments.
28  *
29  * FunVis2D('Property','Value',...) creates a new FunVis2D or raises the
30  * existing singleton*. Starting from the left, property value pairs are
31  * applied to the GUI before FunVis2D_OpeningFcn gets called. An
32  * unrecognized property name or invalid value makes property application
33  * stop. All inputs are passed to FunVis2D_OpeningFcn via varargin.
34  *
35  * *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
36  * instance to run (singleton)".
37  *
38  * See also: GUIDE, GUIDATA, GUIHANDLES */
39 
40 /* Edit the above text to modify the response to help FunVis2D */
41 
42 /* Last Modified by GUIDE v2.5 20-Feb-2013 11:09:00 */
43 
44 /* Begin initialization code - DO NOT EDIT */
45 gui_Singleton = 1;
46 gui_State = struct(" gui_Name ", mfilename, ...
47  " gui_Singleton ", gui_Singleton, ...
48  " gui_OpeningFcn ", @FunVis2D_OpeningFcn, ...
49  " gui_OutputFcn ", @FunVis2D_OutputFcn, ...
50  " gui_LayoutFcn ", [] , ...
51  " gui_Callback ", []);
52 if nargin && ischar(varargin[1])
53  gui_State.gui_Callback= str2func(varargin[1]);
54 end
55 
56 if nargout
57  [varargout[1:nargout]] = gui_mainfcn(gui_State, varargin[:]);
58 else
59  gui_mainfcn(gui_State, varargin[:]);
60 end
61 /* End initialization code - DO NOT EDIT */
62 
63 
64 /* --- Executes just before FunVis2D is made visible. */
65 }
181 function FunVis2D>FunVis2D_OpeningFcn(hObject,eventdata,handles,varargin) {
182 
183 /* Choose default command line output for FunVis2D */
184 handles.output= hObject;
185 
186 /* Update handles structure */
187 guidata(hObject, handles);
188 
189 /* UIWAIT makes FunVis2D wait for user response (see UIRESUME)
190  * uiwait(handles.main); */
191 
192 /* % Custom Code */
193 h = handles;
194 ranges = struct(" xrange ",[]," trange ",[]," murange ",[]);
195 conf = struct;
196 conf.td= [];
197 conf.fun2= [];
198 if isa(varargin[1]," models.BaseFullModel ")
199  m = varargin[1];
200  fun = m.System.f;
201  [x,X] = m.Data.getBoundingBox;
202  ranges.xrange= [x X];
203  ranges.trange= [0 m.T];
204  if m.System.ParamCount > 0
205  if isempty(m.Data.ParamSamples)
206  stop(h," No param samples available yet. Have you run model.off1_generateParamSamples? ");
207  end
208  [mu, MU] = Utils.getBoundingBox(m.Data.ParamSamples);
209  ranges.murange= [mu MU];
210  end
211 elseif isa(varargin[1]," models.ReducedModel ")
212  r = varargin[1];
213  fun = r.System.f;
214  conf.td= r.FullModel.Data.ApproxTrainData;
215  ranges = rangesFromATD(conf.td);
216  conf.fun2= r.FullModel.System.f;
217 else
218  /* % Handle first function argument */
219  fun = varargin[1];
220  if isa(fun," function_handle ")
221  /* Wrap in core fun so that evaluate works
222  * if nargin(fun) == 1
223  * ranges.trange = [0 0];
224  * ranges.murange = [0 0];
225  * end */
226  fun = dscomponents.PointerCoreFun(fun);
227  elseif ~ismethod(fun," evaluate ")
228  stop(h," If the first argument is not a function pointer it must be a class with an 'evaluate' method. ");
229  end
230 
231  /* % Second argument */
232  conf.td= [];
233  sec = varargin[2];
234  if isfield(sec," xrange ")
235  /* Use explicit ranges */
236  ranges.xrange= sec.xrange;
237  if isfield(sec," trange ")
238  ranges.trange= sec.trange;
239  end
240  if isfield(sec," murange ")
241  ranges.murange= sec.murange;
242  end
243  if length(varargin) > 2 && isa(varargin[3]," data.ATrajectoryData ")
244  conf.td= varargin[3].ApproxTrainData;
245  end
246  elseif isa(sec," data.ApproxTrainData ")
247  /* Use the bounds of the training data as ranges */
248  ranges = rangesFromATD(sec);
249  conf.td= sec;
250  elseif isa(sec," double ")
251  ranges.xrange= sec;
252  else
253  stop(h," The second argument has to be a ranges struct or a struct with the fields xrange (+trange,murange if given). ");
254  end
255 end
256 conf.fun= fun;
257 conf.ranges= ranges;
258 
259 /* % Build global bounding box */
260 conf.hastime= false;
261 conf.hasparams= false;
262 box = ranges.xrange;
263 if ~isempty(ranges.trange)
264  conf.hastime= true;
265  conf.timeoff= size(ranges.xrange,1)+1;
266  box = [box; ranges.trange];
267 end
268 if ~isempty(ranges.murange)
269  conf.hasparams= true;
270  conf.paroff= size(ranges.xrange,1)+1;
271  if conf.hastime
272  conf.paroff= conf.paroff+1;
273  end
274  box = [box; ranges.murange];
275 end
276 conf.box= box;
277 conf.xdim= size(ranges.xrange,1);
278 conf.dims= size(box,1);
279 /* Detect constant fields */
280 conf.const= find(max(box,[],2) == min(box,[],2));
281 
282 /* % Fourth argument (anyone who wants to pass second functions or labels
283  *% needs to fill the call with [] fields) */
284 fun2 = []; lbl = [];
285 if length(varargin) > 3
286  fun2 = varargin[4];
287  if isa(fun2," function_handle ")
288  fun2 = dscomponents.PointerCoreFun(fun2,conf.xdim,true);
289  elseif ~isempty(fun2) && ~ismethod(fun2," evaluate ")
290  stop(h," Any second function-class must have an "" evaluate "" -method ");
291  end
292  if length(varargin) > 4
293  lbl = varargin[5];
294  if ~isfield(lbl," x ") || ~isfield(lbl," fx ")
295  stop(h, " Custom labels must have the struct fields x and fx ");
296  end
297  end
298 end
299 if ~isempty(fun2)
300  conf.fun2= fun2;
301 end
302 
303 /* % Use generic labels if none are given */
304 if isempty(lbl)
305  /* Automatically assign "useful" names to the dimensions */
306  lbl = struct;
307  lbl.x= [];
308  for i=setdiff(1:conf.xdim,conf.const)
309  lbl.x[end+1] = [" x_{ " num2str(i) " } "];
310  end
311  args[1] = zeros(conf.xdim,1);
312  if conf.hastime && all(conf.const ~= conf.timeoff)
313  lbl.x[end+1] = " t ";
314  args[2] = 0;
315  else
316  args[2] = double.empty(0,1);
317  end
318  if conf.hasparams
319  munum = 1:size(conf.ranges.murange,1);
320  [diff, idx] = setdiff(conf.paroff+munum-1,conf.const);
321  for i=1:length(diff)
322  lbl.x[end+1] = [" mu_{ " num2str(munum(idx(i))) " } "];
323  end
324  args[3] = zeros(munum,1);
325  else
326  args[3] = double.empty(0,1);
327  end
328  lbl.fx= [];
329  if ~isempty(conf.td)
330  fdim = size(conf.td.fxi,1);
331  else
332  /* Autodetect output size by evaluating with all zero arguments */
333  fdim = size(conf.fun.evaluate(args[:]),1);
334  end
335  for i=1:fdim
336  lbl.fx[end+1] = [" f(x_{ " num2str(i) " }) "];
337  end
338 end
339 conf.lbl= lbl;
340 
341 /* % Check for kernel expansions */
342 conf.iske= false;
343 conf.isptke= false;
344 if isa(fun," kernels.KernelExpansion ")
345  conf.iske= true;
346  set(h.lblCenters," Visible "," on ");
347  set(h.lblNumCenters," Visible "," on ");
348  set(h.slCenters," Visible "," on ");
349  conf.cperc= 3;
350  set(h.slCenters," Value ",conf.cperc);
351 
352  if isa(fun," kernels.ParamTimeKernelExpansion ")
353  conf.isptke= true;
354  end
355 end
356 /* % Visibilities for second function, if given */
357 if ~isempty(conf.fun2)
358  set(handles.lbl2nd," Visible "," on ");
359  set(handles.rbAdd," Visible "," on ");
360  set(handles.rbErr," Visible "," on ");
361 end
362 
363 /* % Setup default values */
364 [~, conf.idxmap] = setdiff(1:conf.dims,conf.const);
365 /* Selected dimensions */
366 conf.d1= 1; conf.d2= 2;
367 conf.dout= 1;
368 /* Refinement factor */
369 conf.gridpts= 60;
370 /* The base x to use, starting with the center of all values */
371 conf.basex= (box(:,1)+box(:,2))/2;
372 
373 /* Use training data display if any is given */
374 if ~isempty(conf.td)
375  /* The percentage of nearest training points to plot along with the approximation */
376  conf.tperc= 3;
377  set(h.slPerc," Value ",conf.tperc);
378 else
379  /* Hide training point selection slider if no td is given. */
380  set(h.slPerc," Visible "," off ");
381  set(h.lblTP," Visible "," off ");
382  set(h.lblPerc," Visible "," off ");
383 end
384 
385 setappdata(h.main," conf ",conf)
386 
387 rotate3d(h.ax," on ");
388 view(h.ax,-53,48);
389 
390 /* % Fill dropdowns & GUI */
391 set(h.dim1," String ",lbl.x," Value ",conf.d1);
392 set(h.dim2," String ",lbl.x," Value ",conf.d2);
393 set(h.dout," String ",lbl.fx," Value ",conf.dout);
394 set(h.slRefine," Value ",conf.gridpts);
395 
396 setDimSliders(h);
397 
398 updateATDPoints(h,conf);
399 conf = updateCenterPoints(h, conf);
400 newMesh(h, conf);
401 
402 }
403 
405  ranges = struct(" xrange ",[]," trange ",[]," murange ",[]);
406  [x, X] = Utils.getBoundingBox(atd.xi.toMemoryMatrix);
407  ranges.xrange= [x X];
408  if isprop(atd," ti ") || isfield(atd," ti ")
409  ranges.trange= [min(atd.ti) max(atd.ti)];
410  end
411  if isprop(atd," mui ") || isfield(atd," mui ")
412  [mu, MU] = Utils.getBoundingBox(atd.mui);
413  ranges.murange= [mu MU];
414  end
415 
416 }
417 
418 function FunVis2D>stop(h,errmsg,varargin) {
419  close(h.main);
420  error(errmsg,varargin[:]);
421 
422 }
423 
424 function FunVis2D>newMesh(h,c) {
425 xsel = c.idxmap([c.d1 c.d2]);
426 x1 = linspace(c.box(xsel(1),1), c.box(xsel(1),2), c.gridpts);
427 x2 = linspace(c.box(xsel(2),1), c.box(xsel(2),2), c.gridpts);
428 
429 [X1,X2] = meshgrid(x1,x2);
430 setappdata(h.main," X1 ",X1);
431 setappdata(h.main," X2 ",X2);
432 
433 updateFX(h, c);
434 
435 }
436 
437 function FunVis2D>updateFX(h,c) {
438 X1 = getappdata(h.main," X1 ");
439 X2 = getappdata(h.main," X2 ");
440 x = [X1(:)" ; X2(:) "];
441 xf = repmat(c.basex,1,size(x,2));
442 xsel = c.idxmap([c.d1 c.d2]);
443 xf(xsel,:) = x;
444 
445 /* Evaluate fcn according to given values */
446 fx2 = [];
447 if c.hastime && c.hasparams
448  fx = c.fun.evaluate(xf(1:c.timeoff-1,:),...
449  xf(c.timeoff,:),...
450  xf(c.paroff:end,:));
451  if ~isempty(c.fun2)
452  fx2 = c.fun2.evaluate(xf(1:c.timeoff-1,:),...
453  xf(c.timeoff,:),...
454  xf(c.paroff:end,:));
455  end
456 elseif c.hastime
457  fx = c.fun.evaluate(xf(1:c.timeoff-1,:),...
458  xf(c.timeoff,:),[]);
459  if ~isempty(c.fun2)
460  fx2 = c.fun2.evaluate(xf(1:c.timeoff-1,:),...
461  xf(c.timeoff,:),[]);
462  end
463 elseif c.hasparams
464  fx = c.fun.evaluate(xf(1:c.paroff-1,:),[],...
465  xf(c.paroff:end,:));
466  if ~isempty(c.fun2)
467  fx2 = c.fun2.evaluate(xf(1:c.paroff-1,:),[],...
468  xf(c.paroff:end,:));
469  end
470 else
471  fx = c.fun.evaluate(xf,[],[]);
472  if ~isempty(c.fun2)
473  fx2 = c.fun2.evaluate(xf,[],[]);
474  end
475 end
476 /* Compute some errors */
477 if ~isempty(c.fun2)
478  n = (1/numel(fx));
479  c.err.l2= sqrt(n*sum((fx-fx2).^2,2));
480  c.err.rel_l2_1= c.err.l2 ./ sqrt(n*sum(fx.^2,2));
481  c.err.rel_l2_2= c.err.l2 ./ sqrt(n*sum(fx2.^2,2));
482  c.err.linf= max(abs(fx-fx2),[],2);
483  setappdata(h.main," conf ",c);
484 end
485 setappdata(h.main," fx ",fx);
486 setappdata(h.main," fx2 ",fx2);
487 
488 plotCurrent(h,c);
489 
490 }
491 
492 function c = FunVis2D>updateCenterPoints(h,c) {
493 if c.iske
494  cent = c.fun.Centers;
495  C = [cent.xi];
496  if c.isptke
497  C = [C; cent.ti; cent.mui];
498  end
499  /* Determine the % closest centers */
500  d = C - repmat(c.basex,1,size(C,2));
501  xsel = c.idxmap([c.d1 c.d2]);
502  d(xsel,:) = [];
503  d = sqrt(sum(d.^2,1));
504  md = min(d); Md = max(d);
505  if md == Md && c.cperc > 0
506  sel = true(size(d));
507  else
508  sel = d < md + (Md-md)*(c.cperc/100)*1.001;
509  end
510  set(h.lblNumCenters," String ",sprintf(" %d/%d ",sum(sel),size(C,2)));
511  C = C(:,sel);
512  c.curCenters= C;
513  c.curCenterSelInATD= [];
514  if ~isempty(c.td)
515  c.curCenterSelInATD= Utils.findVecInMatrix(c.td.xi.toMemoryMatrix,C);
516  if any(c.curCenterSelInATD == 0)
517  c.curCenterSelInATD= [];
518  end
519  end
520  xf = repmat(c.basex,1,size(C,2));
521  xsel = c.idxmap([c.d1 c.d2]);
522  xf(xsel,:) = C(xsel,:);
523  if c.isptke
524  c.curCenterFx= c.fun.evaluate(xf(1:c.timeoff-1,:),...
525  xf(c.timeoff,:),...
526  xf(c.paroff:end,:));
527  else
528  c.curCenterFx= c.fun.evaluate(xf,[],[]);
529  end
530  /* compute error if second function is given */
531  if ~isempty(c.fun2) && get(h.rbErr," Value ") == 1
532  if c.hastime || c.hasparams
533  error(" Error plots with centers for param/time kernel expansions not yet implemented ");
534  end
535  c.curCenterFx= c.curCenterFx - c.fun2.evaluate(xf,[],[]);
536  end
537  setappdata(h.main," conf ",c);
538 end
539 
540 }
541 
543 if ~isempty(c.td)
544  xsel = c.idxmap([c.d1 c.d2]);
545  C = c.td.xi.toMemoryMatrix;
546  if c.isptke || isa(c.fun," dscomponents.ACoreFun ")
547  C = [C; c.td.ti; c.td.mui];
548  end
549  /* Determine the % closest centers */
550  d = C - repmat(c.basex,1,size(C,2));
551  d(xsel,:) = [];
552  d = sqrt(sum(d.^2,1));
553  md = min(d); Md = max(d);
554  if md == Md && c.tperc > 0
555  sel = true(size(d));
556  else
557  sel = d < md + (Md-md)*(c.tperc/100)*1.001;
558  end
559  set(h.lblPerc," String ",sprintf(" %d/%d ",sum(sel),size(C,2)));
560  setappdata(h.main," selATDPoints ",sel);
561 end
562 
563 /* % Plots the current settings */
564 
565 }
566 
567 function FunVis2D>plotCurrent(h,c) {
568 
569 fx = getappdata(h.main," fx ");
570 X1 = getappdata(h.main," X1 ");
571 X2 = getappdata(h.main," X2 ");
572 cap = sprintf(" Plot of %s against %s and %s ",c.lbl.fx[c.dout],c.lbl.x[c.d1],c.lbl.x[c.d2]);
573 mi = Inf; Ma = -Inf;
574 
575 cla(h.ax);
576 hold(h.ax," on ");
577 
578 if get(h.chkPlotFun," Value ") == 1
579 
580  fx = reshape(fx(c.dout,:),size(X1,1),[]);
581 /* fx = gradient(fx); */
582 
583  txt = ;
584  fx2 = getappdata(h.main," fx2 ");
585  if ~isempty(fx2) && get(h.rbErr," Value ") == 1
586  fx2 = reshape(fx2(c.dout,:),size(X1,1),[]);
587  if ~any(isnan(fx2))
588  cap = sprintf(" Error f_1-f_2 at output %s against %s and %s ",c.lbl.fx[c.dout],c.lbl.x[c.d1],c.lbl.x[c.d2]);
589  /* fx = abs(fx-fx2); */
590  fx = fx-fx2;
591  txt = sprintf(" L2:%.2e, Linf:%.2e\nrL21:%.2e, rL22:%.2e ",c.err.l2(c.dout),c.err.linf(c.dout),...
592  c.err.rel_l2_1(c.dout),c.err.rel_l2_2(c.dout));
593  else
594  fprintf(" Warning, current output %s contains NaNs. Not plotting error.\n ",c.lbl.fx[c.dout]);
595  end
596  end
597  set(h.lblErr," String ",txt);
598 
599  mi = min(fx(:));
600  Ma = max(fx(:));
601  if mi == 0 && Ma == 0
602  mi = -eps; Ma = eps;
603  elseif mi ~= 0 && abs((mi-Ma) / mi) < 1e-14
604  s = sign(mi);
605  mi = (1-.001*s)*mi; Ma=(1+.001*s)*Ma;
606  end
607 
608  /* % Plots */
609  s1 = surf(h.ax,X1,X2,fx," FaceColor "," interp ");
610 
611  if ~isempty(fx2) && get(h.rbAdd," Value ") == 1
612  fx2 = reshape(fx2(c.dout,:),size(X1,1),[]);
613  if ~any(isnan(fx2))
614  mi = min(mi,min(fx2(:)));
615  Ma = max(Ma,max(fx2(:)));
616  cap = sprintf(" Plot of %s against %s and %s, both functions ",c.lbl.fx[c.dout],c.lbl.x[c.d1],c.lbl.x[c.d2]);
617  s2 = surf(h.ax,X1,X2,fx2);
618  alpha(s2,.7);
619  s1 = [s1; s2];
620  end
621  end
622  if get(h.rbErr," Value ") == 1
623  s3 = surf(h.ax,X1,X2,zeros(size(X1)));
624  alpha(s3,.7);
625  s1 = [s1; s3];
626  end
627  mode = " none ";
628  if get(h.chkGrid," Value ") == 1
629  mode = " interp ";
630  end
631  set(s1," EdgeColor ",mode);
632 end
633 
634 xsel = c.idxmap([c.d1 c.d2]);
635 /* % Add training data points to plot
636  * With kernel expansions: option to include centers into mesh */
637 if ~isempty(c.td) && get(h.rbErr," Value ") == 0
638  C = c.td.xi.toMemoryMatrix;
639  if c.isptke
640  C = [C; c.td.ti; c.td.mui];
641  end
642  C = C(xsel,:);
643  sel = getappdata(h.main," selATDPoints ");
644  hlpfx = c.td.fxi(c.dout,sel);
645  if min(hlpfx) < mi
646  mi = min(hlpfx);
647  end
648  if max(hlpfx) > Ma
649  Ma = max(hlpfx);
650  end
651  plot3(h.ax,C(1,sel),C(2,sel),hlpfx," red. "," MarkerSize ",12);
652 end
653 
654 /* % Plot center points if desired */
655 if c.iske
656  C = c.curCenters;
657  /* Only plot center at original points if no error is displayed */
658  if get(h.rbErr," Value ") == 0 && ~isempty(c.curCenterSelInATD)
659  /* Also plot the centers at their original value */
660  orig = c.td.fxi(c.dout,c.curCenterSelInATD);
661  plot3(h.ax,C(xsel(1),:),C(xsel(2),:),orig," black. "," MarkerSize ",13);
662  /* Plot a connecting line */
663  if get(h.chkPlotCenterLines," Value ") == 1
664  plot3(h.ax,[C(xsel(1),:); C(xsel(1),:)],[C(xsel(2),:); C(xsel(2),:)],[c.curCenterFx(c.dout,:); orig]," black ");
665  plot3(h.ax,C(xsel(1),:),C(xsel(2),:),c.curCenterFx(c.dout,:)," blackx "," MarkerSize ",5);
666  end
667  else
668  plot3(h.ax,C(xsel(1),:),C(xsel(2),:),c.curCenterFx(c.dout,:)," black. "," MarkerSize ",13);
669  end
670 end
671 /* Adjustments and labelling */
672 axis(h.ax,[X1(1,1) X1(1,end) X2(1,1) X2(end,1) mi Ma]);
673 xlabel(h.ax,c.lbl.x[c.d1]);
674 ylabel(h.ax,c.lbl.x[c.d2]);
675 zlabel(h.ax,c.lbl.fx[c.dout]);
676 title(h.ax,cap);
677 hold(h.ax," off ");
678 grid(h.ax," on ");
679 
680 }
681 
683 val = 1-get(h.panelslide," Value ");
684 c = getappdata(h.main," conf ");
685 /* % Remove old ones if exist */
686 ctrls = getappdata(h.main, " ctrls ");
687 if ~isempty(ctrls)
688  delete(ctrls.labels);
689  delete(ctrls.slides);
690  clear ctrls;
691 end
692 
693 set(h.pnlBS," Units "," pixels ");
694 pos = get(h.pnlBS," Position ");
695 pnlh = pos(4);
696 
697 dims = c.idxmap;
698 dims([c.d1 c.d2]) = [];
699 dist = 6;/* px */
700 
701 height = 16; /* px */
702 
703 eh = dist + height; /* total element height */
704 
705 dispsliders = min(length(dims), floor(pnlh / eh)-1);
706 totalheight = (length(dims)-dispsliders) * eh;
707 if totalheight > pnlh
708  curoffset = totalheight * val;
709  firstidx = floor(curoffset / eh);
710 else
711  set(h.panelslide," Visible "," off ");
712  firstidx = 0;
713 end
714 
715 ctrls.labels= [];
716 ctrls.slides= [];
717 for idx = 1:dispsliders
718  dim = dims(firstidx+idx);
719  top = pnlh-15-idx*eh;
720  name = c.lbl.x[dim];
721  /* Create labels */
722  m = c.box(dim,1);
723  M = c.box(dim,2);
724  tooltip = sprintf(" Range [%1.5e - %1.5e] ",m,M);
725  /* Dimension label */
726  label = uicontrol(" Tag ",[" runtime_lbl_ " name]," Style "," text ",...
727  " Parent ",h.pnlBS," HorizontalAlignment "," left ");
728  set(label," String ",[name " : "]," Units "," pixels "," Position ",[10 top 40 14],...
729  " TooltipString ",tooltip);
730  ctrls.labels(end+1) = label;
731 
732  /* Value label */
733  label = uicontrol(" Tag ",sprintf(" runtime_lbl_val_%d ",idx)," Style "," text ",...
734  " Parent ",h.pnlBS," HorizontalAlignment "," left ",...
735  " TooltipString ",[" Value of " name " for current plot "]);
736  set(label," String ",sprintf(" %2.4e ",c.basex(dim))," Units "," pixels "," Position ",[60 top 90 14],...
737  " TooltipString ",tooltip);
738  ctrls.labels(end+1) = label;
739  valuelabel = label;
740 
741 /* % Min value label
742  * label = uicontrol('Tag',['runtime_lbl_min' name],'Style','text',...
743  * 'Parent',h.pnlBS,'HorizontalAlignment','right',...
744  * 'TooltipString',['Minimum value of ' name]);
745  * set(label,'String',sprintf('%1.1e',m),'Units','pixels','Position',[160 top 50 14]);
746  * ctrls.labels(end+1) = label; */
747 
748  /* Create slider */
749  ctrl = uicontrol(" Tag ",sprintf(" runtime_slide_%d ",idx)," Parent ",...
750  h.pnlBS," HorizontalAlignment "," left ");
751  set(ctrl," Style "," slider ", " Value ", c.basex(dim),...
752  " Min ", m, " Max ", M);
753  set(ctrl," Units "," pixels "," Position ",[160 top 250 16]," UserData ",dim,...
754  " TooltipString ",tooltip);
755  set(ctrl," Callback ",@(h,e)(baseSliderChanged(h,guidata(h),valuelabel)));
756  ctrls.slides(end+1) = ctrl;
757 
758  /* Max value label
759  * label = uicontrol('Tag',['runtime_lbl_max' name],'Style','text',...
760  * 'Parent',h.pnlBS,'HorizontalAlignment','left',...
761  * 'TooltipString',['Maximum value of ' name]);
762  * set(label,'String',sprintf('%1.1e',M),'Units','pixels','Position',[350 top 50 14]);
763  * ctrls.labels(end+1) = label; */
764 end
765 setappdata(h.main, " ctrls ", ctrls);
766 
767 }
768 
769 function FunVis2D>baseSliderChanged(hObj,h,label) {
770 dim = get(hObj," UserData ");
771 conf = getappdata(h.main," conf ");
772 conf.basex(dim) = get(hObj," Value ");
773 set(label," String ",sprintf(" %2.4e ",conf.basex(dim)));
774 setappdata(h.main," conf ",conf);
775 
776 updateATDPoints(h,conf);
777 conf = updateCenterPoints(h,conf);
778 updateFX(h, conf);
779 
780 }
781 
782 function varargout = FunVis2D>FunVis2D_OutputFcn(hObject,eventdata,handles) {
783 
784 /* Get default command line output from handles structure */
785 varargout[1] = FunVis2DHandler(handles.main);
786 
787 }
788 
789 function FunVis2D>dim1_Callback(hObject,eventdata,handles) {
790 conf = getappdata(handles.main," conf ");
791 if get(hObject," Value ") ~= conf.d2
792  old = conf.d1;
793  conf.d1= get(hObject," Value ");
794  setappdata(handles.main," conf ",conf);
795 
796  setDimSliders(handles);
797  newMesh(handles, conf);
798 end
799 
800 }
801 
802 function FunVis2D>dim1_CreateFcn(hObject,eventdata,handles) {
803 if ispc && isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
804  set(hObject," BackgroundColor "," white ");
805 end
806 
807 }
808 
809 function FunVis2D>dim2_Callback(hObject,eventdata,handles) {
810 conf = getappdata(handles.main," conf ");
811 if get(hObject," Value ") ~= conf.d1
812  old = conf.d2;
813  conf.d2= get(hObject," Value ");
814  setappdata(handles.main," conf ",conf);
815 
816  setDimSliders(handles);
817  newMesh(handles, conf);
818 end
819 
820 }
821 
822 function FunVis2D>dim2_CreateFcn(hObject,eventdata,handles) {
823 
824 /* Hint: popupmenu controls usually have a white background on Windows.
825  * See ISPC and COMPUTER. */
826 if ispc && isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
827  set(hObject," BackgroundColor "," white ");
828 end
829 
830 
831 /* --- Executes on slider movement. */
832 }
833 
834 function FunVis2D>slRefine_Callback(hObject,eventdata,handles) {
835 
836 /* Hints: get(hObject,'Value') returns position of slider
837  * get(hObject,'Min') and get(hObject,'Max') to determine range of slider */
838 c = getappdata(handles.main," conf ");
839 c.gridpts= round(get(hObject," Value "));
840 set(handles.lblRef," String ",num2str(c.gridpts));
841 setappdata(handles.main," conf ",c);
842 newMesh(handles, c);
843 
844 /* --- Executes during object creation, after setting all properties. */
845 }
846 
847 function FunVis2D>slRefine_CreateFcn(hObject,eventdata,handles) {
848 
849 /* Hint: slider controls usually have a light gray background. */
850 if isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
851  set(hObject," BackgroundColor ",[.9 .9 .9]);
852 end
853 
854 
855 /* --- Executes on selection change in dout. */
856 }
857 
858 function FunVis2D>dout_Callback(hObject,eventdata,handles) {
859 
860 /* Hints: contents = get(hObject,'String') returns dout contents as cell array
861  * contents{get(hObject,'Value')} returns selected item from dout */
862 conf = getappdata(handles.main," conf ");
863 conf.dout= get(hObject," Value ");
864 setappdata(handles.main," conf ",conf);
865 plotCurrent(handles, conf);
866 
867 /* --- Executes during object creation, after setting all properties. */
868 }
869 
870 function FunVis2D>dout_CreateFcn(hObject,eventdata,handles) {
871 
872 /* Hint: popupmenu controls usually have a white background on Windows.
873  * See ISPC and COMPUTER. */
874 if ispc && isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
875  set(hObject," BackgroundColor "," white ");
876 end
877 
878 
879 /* --- Executes on slider movement. */
880 }
881 
882 function FunVis2D>slPerc_Callback(hObject,unused1,handles) {
883 conf = getappdata(handles.main," conf ");
884 conf.tperc= get(hObject," Value ");
885 set(handles.lblTP," String ",sprintf(" Select %2.2f%% nearest training points ",conf.tperc));
886 
887 setappdata(handles.main," conf ",conf);
888 updateATDPoints(handles, conf);
889 plotCurrent(handles,conf);
890 
891 /* --- Executes during object creation, after setting all properties. */
892 }
893 
894 function FunVis2D>slPerc_CreateFcn(hObject,eventdata,handles) {
895 
896 /* Hint: slider controls usually have a light gray background. */
897 if isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
898  set(hObject," BackgroundColor ",[.9 .9 .9]);
899 end
900 
901 }
902 
903 function FunVis2D>panelslide_Callback(hObject,eventdata,h) {
904 
905 /* Hints: get(hObject,'Value') returns position of slider
906  * get(hObject,'Min') and get(hObject,'Max') to determine range of slider */
907 setDimSliders(h);
908 
909 }
910 
911 function FunVis2D>panelslide_CreateFcn(hObject,eventdata,handles) {
912 
913 /* Hint: slider controls usually have a light gray background. */
914 if isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
915  set(hObject," BackgroundColor ",[.9 .9 .9]);
916 end
917 
918 }
919 
920 function FunVis2D>uipushtool2_ClickedCallback(hObject,eventdata,handles) {
921 Utils.saveAxes(handles.ax);
922 
923 }
924 
925 function FunVis2D>slCenters_Callback(hObject,unused1,handles) {
926 
927 /* Hints: get(hObject,'Value') returns position of slider
928  * get(hObject,'Min') and get(hObject,'Max') to determine range of slider */
929 c = getappdata(handles.main," conf ");
930 c.cperc= get(hObject," Value ");
931 set(handles.lblCenters," String ",sprintf(" Include %2.2f%% nearest centers ",c.cperc));
932 setappdata(handles.main," conf ",c);
933 c = updateCenterPoints(handles, c);
934 plotCurrent(handles,c);
935 
936 }
937 
938 function FunVis2D>slCenters_CreateFcn(hObject,eventdata,handles) {
939 
940 /* Hint: slider controls usually have a light gray background. */
941 if isequal(get(hObject," BackgroundColor "), get(0," defaultUicontrolBackgroundColor "))
942  set(hObject," BackgroundColor ",[.9 .9 .9]);
943 end
944 
945 }
946 
947 function FunVis2D>rbAdd_Callback(hObject,eventdata,handles) {
948 set(handles.rbErr," Value ",0);
949 c = updateCenterPoints(handles, getappdata(handles.main," conf "));
950 plotCurrent(handles,c);
951 
952 }
953 
954 function FunVis2D>rbErr_Callback(hObject,eventdata,handles) {
955 set(handles.rbAdd," Value ",0);
956 c = updateCenterPoints(handles, getappdata(handles.main," conf "));
957 plotCurrent(handles,c);
958 
959 /* --- Executes on button press in chkGrid. */
960 }
961 
962 function FunVis2D>chkGrid_Callback(hObject,eventdata,handles) {
963 
964 /* Hint: get(hObject,'Value') returns toggle state of chkGrid */
965 plotCurrent(handles,getappdata(handles.main," conf "));
966 
967 /* --- Executes on button press in chkPlotFun. */
968 }
969 
970 function FunVis2D>chkPlotFun_Callback(hObject,eventdata,handles) {
971 plotCurrent(handles,getappdata(handles.main," conf "));
972 
973 
974 /* --- Executes on button press in chkPlotCenterLines. */
975 }
976 
977 function FunVis2D>chkPlotCenterLines_Callback(hObject,unused1,handles) {
978 plotCurrent(handles,getappdata(handles.main," conf "));
979 
980 }
981 
Collection of generally useful functions.
Definition: Utils.m:17
function FunVis2D>slPerc_Callback(hObject, unused1, handles)
Definition: FunVis2D.m:882
data.FileMatrix xi
The state space samples , stored row-wise in a data.FileMatrix instance.
function FunVis2D>slRefine_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:834
function ranges = FunVis2D>rangesFromATD(data.ApproxTrainData atd)
Definition: FunVis2D.m:404
function FunVis2D>newMesh(h, c)
Definition: FunVis2D.m:424
function FunVis2D>dout_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:858
static function idx = findVecInMatrix(A, b)
Finds column vectors inside a matrix.
Definition: Utils.m:259
function FunVis2D>FunVis2D_OpeningFcn(hObject, eventdata, handles, varargin)
Definition: FunVis2D.m:181
function FunVis2D>setDimSliders(h)
Definition: FunVis2D.m:682
function FunVis2D>chkGrid_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:962
function FunVis2D>slCenters_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:938
function FunVis2D>rbAdd_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:947
function FunVis2D>slPerc_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:894
function varargout = FunVis2D(varargin)
User interface to visualize highdimensional functions using two input dimensions and one output dimen...
Definition: FunVis2D.m:17
function FunVis2D>dout_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:870
function varargout = FunVis2D>FunVis2D_OutputFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:782
FunVis2DHandler:
rowvec ti
The time samples .
function FunVis2D>slCenters_Callback(hObject, unused1, handles)
Definition: FunVis2D.m:925
A variable number of input arguments.
function FunVis2D>rbErr_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:954
function FunVis2D>dim1_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:789
function FunVis2D>stop(h, errmsg, varargin)
Definition: FunVis2D.m:418
function FunVis2D>panelslide_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:911
#define X(i, j)
function FunVis2D>panelslide_Callback(hObject, eventdata, h)
Definition: FunVis2D.m:903
Speed test * all(1:3)
function FunVis2D>slRefine_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:847
function c = FunVis2D>updateCenterPoints(h, c)
Definition: FunVis2D.m:492
matrix mui
The parameter samples used computing the parent trajectories of .
function FunVis2D>uipushtool2_ClickedCallback(hObject, eventdata, handles)
Definition: FunVis2D.m:920
function FunVis2D>chkPlotCenterLines_Callback(hObject, unused1, handles)
Definition: FunVis2D.m:977
function FunVis2D>baseSliderChanged(hObj, h, label)
Definition: FunVis2D.m:769
ApproxTrainData: Data class for approximation training data, containing several useful bounding box p...
function A = toMemoryMatrix()
Converts this FileMatrix to a full double matrix.
Definition: ABlockedData.m:210
function FunVis2D>chkPlotFun_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:970
function FunVis2D>updateFX(h, c)
Definition: FunVis2D.m:437
function FunVis2D>dim1_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:802
static function saveAxes(handle ax, varargin)
Convenience function. Allows to save a custom axes instead of a whole figure which allows to drop any...
Definition: Utils.m:437
function FunVis2D>dim2_CreateFcn(hObject, eventdata, handles)
Definition: FunVis2D.m:822
static function [ double bmin , double bmax ] = getBoundingBox(double vectors)
Gets the bounding box for a matrix containing column vectors.
Definition: Utils.m:96
A variable number of output arguments.
function FunVis2D>updateATDPoints(h, c)
Definition: FunVis2D.m:542
function FunVis2D>dim2_Callback(hObject, eventdata, handles)
Definition: FunVis2D.m:809
function FunVis2D>plotCurrent(h, c)
Definition: FunVis2D.m:567