From 5f97d975de850b3e8367b13cfccf66aef6517ee5 Mon Sep 17 00:00:00 2001 From: Karthik Chandrashekara Date: Sun, 11 Jul 2021 06:31:30 +0200 Subject: [PATCH] Added the option to plot the confidence interval. --- .../@MOTSimulator/doOneParameterScan.m | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MOT Capture Process Simulation/@MOTSimulator/doOneParameterScan.m b/MOT Capture Process Simulation/@MOTSimulator/doOneParameterScan.m index 1deaf23..9bf974d 100644 --- a/MOT Capture Process Simulation/@MOTSimulator/doOneParameterScan.m +++ b/MOT Capture Process Simulation/@MOTSimulator/doOneParameterScan.m @@ -1,4 +1,4 @@ -function [LoadingRateArray, StandardErrorArray] = doOneParameterScan(this, ParameterName, ParameterArray, varargin) +function [LoadingRateArray, StandardErrorArray, ConfidenceIntervalArray] = doOneParameterScan(this, ParameterName, ParameterArray, varargin) p = inputParser; p.KeepUnmatched = true; @@ -30,6 +30,7 @@ function [LoadingRateArray, StandardErrorArray] = doOneParameterScan(this, Param NumberOfPointsForParam = length(ParameterArray); LoadingRateArray = zeros(1,NumberOfPointsForParam); StandardErrorArray = zeros(1,NumberOfPointsForParam); + ConfidenceIntervalArray = zeros(NumberOfPointsForParam, 2); for i=1:NumberOfPointsForParam eval(sprintf('OptionsStruct.%s = %d;', ParameterName, ParameterArray(i))); @@ -44,18 +45,21 @@ function [LoadingRateArray, StandardErrorArray] = doOneParameterScan(this, Param options = Helper.convertstruct2cell(OptionsStruct); this.setInitialConditions(options{:}); tic - [LoadingRate, StandardError] = this.runSimulation(); + [LoadingRate, StandardError, ConfidenceInterval] = this.runSimulation(); LoadingRateArray(i) = LoadingRate; StandardErrorArray(i) = StandardError; + ConfidenceIntervalArray(i,1) = ConfidenceInterval(1); + ConfidenceIntervalArray(i,2) = ConfidenceInterval(2); 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')]; + LoadingRate.CI = ConfidenceIntervalArray; + 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));