function [LoadingRateArray, StandardErrorArray, ConfidenceIntervalArray] = doTwoParameters(ovenObj, MOTobj, BeamName, FirstBeamParameter, ... FirstParameterArray, SecondBeamParameter, SecondParameterArray) Beams = MOTobj.Beams; Beam = Beams{cellfun(@(x) strcmpi(x.Alias, BeamName), Beams)}; 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('Beam.%s = %d;', FirstBeamParameter, FirstParameterArray(i))); for j=1:NumberOfPointsForSecondParam eval(sprintf('Beam.%s = %d;', SecondBeamParameter, SecondParameterArray(j))); [LoadingRateArray(i,j), StandardErrorArray(i,j), ConfidenceIntervalArray(i,j,:)] = MOTobj.runSimulation(ovenObj); end end if MOTobj.DoSave LoadingRate = struct; LoadingRate.Values = LoadingRateArray; LoadingRate.Errors = StandardErrorArray; LoadingRate.CI = ConfidenceIntervalArray; MOTobj.Results = LoadingRate; SaveFolder = [MOTobj.SaveDirectory filesep 'Results']; Filename = ['TwoParameterScan_' datestr(now,'yyyymmdd_HHMM')]; eval([sprintf('%s_Object', Filename) ' = MOTobj;']); mkdir(SaveFolder); save([SaveFolder filesep Filename], sprintf('%s_Object', Filename)); end end