function [LoadingRateArray, StandardErrorArray] = doOneParameterScan(this, ParameterName, ParameterArray, varargin) p = inputParser; p.KeepUnmatched = true; addRequired(p, 'ClassObject' , @isobject); addRequired(p, 'ParameterName' , @ischar); addRequired(p, 'ParameterArray' , @isvector); addParameter(p, 'ChangeRelatedParameter', false, @islogical); addParameter(p, 'RelatedParameterName', 'none', @ischar); addParameter(p, 'RelatedParameterArray', length(ParameterArray), @isvector); addParameter(p, 'ChangeInitialConditions', false, @islogical); addParameter(p, 'ParameterNameArray', {}, @iscell); addParameter(p, 'ParameterValueArray', {}, @iscell); p.parse(this, ParameterName, ParameterArray, varargin{:}) ParameterName = p.Results.ParameterName; ParameterArray = p.Results.ParameterArray; ChangeRelatedParameter = p.Results.ChangeRelatedParameter; RelatedParameterName = p.Results.RelatedParameterName; RelatedParameterArray = p.Results.RelatedParameterArray; ChangeInitialConditions = p.Results.ChangeInitialConditions; ParameterNameArray = p.Results.ParameterNameArray; ParameterValueArray = p.Results.ParameterValueArray; NumberOfPointsForParam = length(ParameterArray); LoadingRateArray = zeros(1,NumberOfPointsForParam); StandardErrorArray = zeros(1,NumberOfPointsForParam); for i=1:NumberOfPointsForParam eval(sprintf('OptionsStruct.%s = %d;', ParameterName, ParameterArray(i))); if ChangeRelatedParameter eval(sprintf('OptionsStruct.%s = %d;', RelatedParameterName, RelatedParameterArray(i))); end if ChangeInitialConditions for j = 1:length(ParameterNameArray) eval(sprintf('OptionsStruct.%s = %d;', ParameterNameArray{j}, ParameterValueArray{j})); end end options = Helper.convertstruct2cell(OptionsStruct); this.setInitialConditions(options{:}); tic [LoadingRate, StandardError] = this.runSimulation(); LoadingRateArray(i) = LoadingRate; StandardErrorArray(i) = StandardError; end if this.DoSave LoadingRate = struct; LoadingRate.Values = LoadingRateArray; LoadingRate.Errors = StandardErrorArray; this.Results = LoadingRate; SaveFolder = [this.SaveDirectory filesep 'Results']; Filename = ['OneParameterScan_' datestr(now,'yyyymmdd_HHMM')]; eval([sprintf('%s_Object', Filename) ' = this;']); mkdir(SaveFolder); save([SaveFolder filesep Filename], sprintf('%s_Object', Filename)); end end