function [LoadingRateArray, StandardErrorArray, ConfidenceIntervalArray] = doTwoParameterScan(this, FirstParameterName, FirstParameterArray, ... SecondParameterName, SecondParameterArray, varargin) p = inputParser; p.KeepUnmatched = true; addRequired(p, 'ClassObject' , @isobject); addRequired(p, 'FirstParameterName' , @ischar); addRequired(p, 'FirstParameterArray' , @isvector); addRequired(p, 'SecondParameterName' , @ischar); addRequired(p, 'SecondParameterArray', @isvector); addParameter(p, 'ChangeRelatedParameter', false, @islogical); addParameter(p, 'Order', 1, @(x) assert(isnumeric(x) && isscalar(x) && (x > 0) && (x < 3))); addParameter(p, 'RelatedParameterName', 'none', @ischar); addParameter(p, 'RelatedParameterArray', length(FirstParameterArray), @isvector); addParameter(p, 'ChangeInitialConditions', false, @islogical); addParameter(p, 'ParameterNameArray', {}, @iscell); addParameter(p, 'ParameterValueArray', {}, @iscell); p.parse(this, FirstParameterName, FirstParameterArray, ... SecondParameterName, SecondParameterArray, varargin{:}) FirstParameterName = p.Results.FirstParameterName; FirstParameterArray = p.Results.FirstParameterArray; SecondParameterName = p.Results.SecondParameterName; SecondParameterArray = p.Results.SecondParameterArray; ChangeRelatedParameter = p.Results.ChangeRelatedParameter; Order = p.Results.Order; RelatedParameterName = p.Results.RelatedParameterName; RelatedParameterArray = p.Results.RelatedParameterArray; ChangeInitialConditions = p.Results.ChangeInitialConditions; ParameterNameArray = p.Results.ParameterNameArray; ParameterValueArray = p.Results.ParameterValueArray; NumberOfPointsForFirstParam = length(FirstParameterArray); NumberOfPointsForSecondParam = length(SecondParameterArray); LoadingRateArray = zeros(NumberOfPointsForFirstParam, NumberOfPointsForSecondParam); StandardErrorArray = zeros(NumberOfPointsForFirstParam, NumberOfPointsForSecondParam); ConfidenceIntervalArray = zeros(NumberOfPointsForFirstParam, NumberOfPointsForSecondParam, 2); for i=1:NumberOfPointsForFirstParam eval(sprintf('OptionsStruct.%s = %d;', FirstParameterName, FirstParameterArray(i))); if ChangeRelatedParameter && Order == 1 eval(sprintf('OptionsStruct.%s = %d;', RelatedParameterName, RelatedParameterArray(i))); end for j=1:NumberOfPointsForSecondParam eval(sprintf('OptionsStruct.%s = %d;', SecondParameterName, SecondParameterArray(j))); if ChangeRelatedParameter && Order == 2 eval(sprintf('OptionsStruct.%s = %d;', RelatedParameterName, RelatedParameterArray(j))); end if ChangeInitialConditions for k = 1:length(ParameterNameArray) eval(sprintf('OptionsStruct.%s = %d;', ParameterNameArray{k}, ParameterValueArray{k})); end end options = Helper.convertstruct2cell(OptionsStruct); this.setInitialConditions(options{:}); tic [LoadingRate, StandardError, ConfidenceInterval] = this.runSimulation(); LoadingRateArray(i, j) = LoadingRate; StandardErrorArray(i, j) = StandardError; ConfidenceIntervalArray(i, j, 1) = ConfidenceInterval(1); ConfidenceIntervalArray(i, j, 2) = ConfidenceInterval(2); end end if this.DoSave LoadingRate = struct; LoadingRate.Values = LoadingRateArray; LoadingRate.Errors = StandardErrorArray; LoadingRate.CI = ConfidenceIntervalArray; this.Results = LoadingRate; SaveFolder = [this.SaveDirectory filesep 'Results']; Filename = ['TwoParameterScan_' datestr(now,'yyyymmdd_HHMM')]; eval([sprintf('%s_Object', Filename) ' = this;']); mkdir(SaveFolder); save([SaveFolder filesep Filename], sprintf('%s_Object', Filename)); end end