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
ParamSweep2D.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 [h , Y , E ] = ParamSweep2D(rmodel,mu,inputidx,matrix<integer> params,rowvec<double> range1,rowvec<double> range2,handle ax) {
18 
19 
20 /* Validity checks */
21 [pname[1:2]] = rmodel.System.Params(params).Name;
22 if size(range1,2) == 0 || size(range2,2) == 0
23  error(" Parameter ranges to sweep must be given. ");
24 end
25 if nargin < 7
26  h = figure;
27  ax = gca(h);
28 end
29 
30 p = 0;
31 [MU1, MU2] = meshgrid(range1,range2);
32 
33 pi = ProcessIndicator(" Starting parameter sweep for '%s' and '%s' (%d runs)... ",numel(MU1),false,...
34  pname[1],pname[2],numel(MU1));
35 
36 mu(params(1)) = range1(1);
37 mu(params(2)) = range2(1);
38 [~, y] = rmodel.simulate(mu, inputidx);
39 if size(y,1) > 1
40  error(" PlotParamSweep only applicable for onedimensional system output. ");
41 end
42 
43 Y = zeros(size(MU1));
44 Y(1,1) = y(end);
45 if rmodel.ErrorEstimator.Enabled
46  E = zeros(size(MU1));
47  E(1,1) = rmodel.ErrorEstimator.OutputError(end);
48 else
49  E = [];
50 end
51 
52 /* Iterate over parameter values */
53 pi.step;
54 for idx = 2:numel(MU1)
55  mu(params(1)) = MU1(idx);
56  mu(params(2)) = MU2(idx);
57  [~, y] = rmodel.simulate(mu, inputidx);
58  Y(idx) = y(end);
59 
60  if rmodel.ErrorEstimator.Enabled
61  E(idx) = rmodel.ErrorEstimator.OutputError(end);
62  end
63  pi.step;
64 end
65 pi.stop;
66 
67 /* % Prepare plot */
68 tit = sprintf(" Outputs at T=%1.2f for 2D parameter sweep, base \\mu = [%s]\n'%s' (idx:%d) from %1.3f to %1.3f\n'%s' (idx:%d) from %1.3f to %1.3f ",...
69  rmodel.T,num2str(mu^t),pname[1],params(1),range1(1),range1(end),pname[2],params(2),range2(1),range2(end));
70 
71 /* % Upper bound */
72 if rmodel.ErrorEstimator.Enabled
73  obj = surf(ax,MU1,MU2,Y+E," EdgeColor "," none "," FaceColor "," red ");
74  alpha(obj,.3);
75 /* mesh(T,MU,Y+E,'EdgeColor','none','FaceColor','red'); */
76  hold on;
77 end
78 
79 /* % y plot */
80 surf(ax,MU1,MU2,Y," EdgeColor "," none ");
81 colormap jet;
82 title(tit);
83 xlabel(sprintf(" Parameter %d: %s ",params(1),pname[1]));
84 ylabel(sprintf(" Parameter %d: %s ",params(2),pname[2]));
85 
86 /* % Lower bound */
87 if rmodel.ErrorEstimator.Enabled
88  obj = surf(ax,MU1,MU2,Y-E," EdgeColor "," none "," FaceColor "," red ");
89  alpha(obj,.3);
90 /* mesh(T,MU,Y-E,'EdgeColor','none','FaceColor','red'); */
91  hold off;
92 end
93 }
Matlab's base handle class (documentation generation substitute)
#define Y(i, j)
function [ h , Y , E ] = ParamSweep2D(rmodel, mu, inputidx,matrix< integer > params,rowvec< double > range1,rowvec< double > range2,handle ax)
ParamSweep: Plots the output with error bounds for a range of one specified parameter.
Definition: ParamSweep2D.m:17
ProcessIndicator: A simple class that indicates process either via waitbar or text output...