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. ");
31 [MU1, MU2] = meshgrid(range1,range2);
33 pi =
ProcessIndicator(
" Starting parameter sweep for '%s' and '%s' (%d runs)... ",numel(MU1),
false,...
34 pname[1],pname[2],numel(MU1));
36 mu(params(1)) = range1(1);
37 mu(params(2)) = range2(1);
38 [~, y] = rmodel.simulate(mu, inputidx);
40 error(
" PlotParamSweep only applicable for onedimensional system output. ");
45 if rmodel.ErrorEstimator.Enabled
47 E(1,1) = rmodel.ErrorEstimator.OutputError(end);
54 for idx = 2:numel(MU1)
55 mu(params(1)) = MU1(idx);
56 mu(params(2)) = MU2(idx);
57 [~, y] = rmodel.simulate(mu, inputidx);
60 if rmodel.ErrorEstimator.Enabled
61 E(idx) = rmodel.ErrorEstimator.OutputError(end);
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));
72 if rmodel.ErrorEstimator.Enabled
73 obj = surf(ax,MU1,MU2,Y+E,
" EdgeColor ",
" none ",
" FaceColor ",
" red ");
80 surf(ax,MU1,MU2,Y,
" EdgeColor ",
" none ");
83 xlabel(sprintf(
" Parameter %d: %s ",params(1),pname[1]));
84 ylabel(sprintf(
" Parameter %d: %s ",params(2),pname[2]));
87 if rmodel.ErrorEstimator.Enabled
88 obj = surf(ax,MU1,MU2,Y-E,
" EdgeColor ",
" none ",
" FaceColor ",
" red ");
Matlab's base handle class (documentation generation substitute)
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.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...