% Procedure: RetrieveMeanCollapseCapacityForAPeriodAndRecordSet.m
% -------------------
% This function returns the mean (actually the exp(meanLn(Sa,col))) for a
% given period using a given record set.  I tested this function and it
% works correctly!
%
% Author: Curt Haselton 
% Date Written: 9-28-05
%
% Sources of Code: Some information was taken from Paul Cordovas processing file called "ProcessData.m".
%
% Functions and Procedures called: none
%
% Variable definitions: 
%
% Units: Whatever OpenSees is using - just be consistent!
%
% -------------------
function[meanSaCollapse] = RetrieveMeanCollapseCapacityForAPeriodAndRecordSet(currentPeriodForIM, currentRecordSetIndex, outputFolderName);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Open the file that has the fitten lognormal collapse CDF for the IM of this period
% (for all EQ sets)
    % Go to the output folder
    currentDir = [pwd];
    cd ..;
    cd ..;
    cd Output;
    cd(outputFolderName);
    
    % Make the file name and open the file
    fileName = sprintf('CollapseCDFResults_LogNormalFits_T=%.2f.mat', currentPeriodForIM);
    load(fileName);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Return the exp(meanLn(Sa,col)) as the mean..
    meanSaCollapse = exp(currentMeanLnSaColLIST(currentRecordSetIndex));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Back to the original folder
cd(currentDir);

