diff --git a/src/EaRL_App.mlapp b/src/EaRL_App.mlapp index c869047..62d24e5 100644 Binary files a/src/EaRL_App.mlapp and b/src/EaRL_App.mlapp differ diff --git a/src/Fit_Hazard_4Poly.m b/src/Fit_Hazard_4Poly.m deleted file mode 100644 index e48cc2a..0000000 --- a/src/Fit_Hazard_4Poly.m +++ /dev/null @@ -1,41 +0,0 @@ -function [MAF,Hazard_Sa]=Fit_Hazard_4Poly(HazardCurveData,IMpoints,nIMpoints) - -% Fitting a 4th order polynomial to the hazard curve -IM=HazardCurveData(:,1)'; -MAF_IM=HazardCurveData(:,2)'; -COEFF=polyfit(log(IM),log(MAF_IM),4); -dIM=diff(IMpoints); -MIDPTS=zeros(nIMpoints+1,1); -for i=1:nIMpoints - MIDPTS(i,1)=IMpoints(i)-dIM(1)/2; - if MIDPTS(i,1)<0; MIDPTS(i,1)=IMpoints(i); end - if i==nIMpoints - MIDPTS(i+1,1)=IMpoints(i)+dIM(1)/2; - end -end -MAF=exp(COEFF(1)*log(MIDPTS(:,1)).^4+COEFF(2)*log(MIDPTS(:,1)).^3+COEFF(3)*log(MIDPTS(:,1)).^2+COEFF(4)*log(MIDPTS(:,1)).^1+COEFF(5)); - -for i=1: size(MAF,1)-1 - r=-1*log(1-0.5)/100; - if MAF(i,1)>=r && MAF(i+1,1)<=r - Hazard_Sa.x50_in_100= IMpoints(1,i); - end - r=-1*log(1-0.5)/50; - if MAF(i,1)>=r && MAF(i+1,1)<=r - Hazard_Sa.x50_in_50= IMpoints(1,i); - end - r=-1*log(1-0.1)/50; - if MAF(i,1)>=r && MAF(i+1,1)<=r - Hazard_Sa.x10_in_50= IMpoints(1,i); - end - r=-1*log(1-0.05)/50; - if MAF(i,1)>=r && MAF(i+1,1)<=r - Hazard_Sa.x5_in_50= IMpoints(1,i); - end - r=-1*log(1-0.02)/50; - if MAF(i,1)>=r && MAF(i+1,1)<=r - Hazard_Sa.x2_in_50= IMpoints(1,i); - end -end - -end \ No newline at end of file diff --git a/src/Fit_Hazard_4Poly.p b/src/Fit_Hazard_4Poly.p new file mode 100644 index 0000000..67d965d Binary files /dev/null and b/src/Fit_Hazard_4Poly.p differ diff --git a/src/Get_Collapse_Fragility_IDA.m b/src/Get_Collapse_Fragility_IDA.m deleted file mode 100644 index 2a322e8..0000000 --- a/src/Get_Collapse_Fragility_IDA.m +++ /dev/null @@ -1,58 +0,0 @@ -function [EmpDist, MedianCPS, SigmaCPS]=Get_Collapse_Fragility_IDA (CollapseSDR) -global MainDirectory ProjectName ProjectPath -clc; -cd (ProjectPath) -load(ProjectName,'N_GM','ResponseDataFolderPath','IDAFilename','CollapseSDR','IMend') -cd (MainDirectory) - -dirResult = dir(ResponseDataFolderPath); -allDirs = dirResult([dirResult.isdir]); -allSubDirs = allDirs(3:end); - -% Loop for GMs to Read Thier Collapse SA Values -for GM_No=1:N_GM - thisDir = allSubDirs(GM_No); - thisDirName = thisDir.name; - cd (ResponseDataFolderPath); - cd(num2str(thisDirName)) - - - % Read IDA Max Data File - IDA_SDR = importdata(IDAFilename.SDR); - - Sa = IDA_SDR (:,1); - for i=1:size(IDA_SDR,1) - IDA_SDR_Max (i,1)= max(IDA_SDR (i,2:end)); % get the maximum SDR in the building at each SA intensity - end - - % Loop over the maximum SDR values and if it exceeds the pre-defined - % CollaspeSDR, interpolate to find the collapse SA - for i=2:size(IDA_SDR_Max,1) - if IDA_SDR_Max (i,1) > CollapseSDR - MaxSa(GM_No,1)=interp1(IDA_SDR_Max (i-1:i,1),Sa (i-1:i,1),CollapseSDR); - break - else - MaxSa(GM_No,1)=Sa(end,1); - end - end - cd (MainDirectory); - - clear IDA_SDR IDA_SDR_Max Sa -end - -MaxSa=sort (MaxSa,1); % Sort the Collapse SA Vector in Asscending Order - -for i=1:size(MaxSa,1) - EmpDist(i,1)=MaxSa(i,1); - EmpDist(i,2)=i/N_GM; -end - -Parameters=lognfit(MaxSa); -MedianCPS=Parameters(1); -SigmaCPS=Parameters(2); -if max(MaxSa)==min(MaxSa) - MedianCPS=IMend; - SigmaCPS=0.001; -end - -end \ No newline at end of file diff --git a/src/Get_Collapse_Fragility_IDA.p b/src/Get_Collapse_Fragility_IDA.p new file mode 100644 index 0000000..a607294 Binary files /dev/null and b/src/Get_Collapse_Fragility_IDA.p differ diff --git a/src/Get_Collapse_Fragility_Parameters.m b/src/Get_Collapse_Fragility_Parameters.m deleted file mode 100644 index 4df6a99..0000000 --- a/src/Get_Collapse_Fragility_Parameters.m +++ /dev/null @@ -1,52 +0,0 @@ -function [CollapseSDR,CPS_Option,MedianCPS,SigmaCPS,Pcollapse,PcollapseSa]=Get_Collapse_Fragility_Parameters(app) - - -if app.radio1.Value==1 - CPS_Option=0; - MedianCPS = 10; - SigmaCPS = 0.001; - Pcollapse=1; - PcollapseSa=1; - CollapseSDR=0.15; -end - -if app.radio2.Value==1 - CPS_Option=1; - CollapseSDR=app.edit1.Value; - [EmpDist,MedianCPS, SigmaCPS]=Get_Collapse_Fragility_IDA(CollapseSDR); - MedianCPS=exp(MedianCPS); - Pcollapse=1; - PcollapseSa=1; -end - -if app.radio3.Value==1 - CPS_Option=2; - MedianCPS = app.edit2.Value; - SigmaCPS = app.edit3.Value; - Pcollapse=1; - PcollapseSa=1; - CollapseSDR=0.15; -end - -if app.radio4.Value - CPS_Option=3; - Pcollapse = app.edit4.Value/100; - PcollapseSa = app.edit5.Value; - SigmaCPS = app.edit6.Value; - CollapseSDR=0.15; - - % Get the median Sa at collaspe that satisifies the entered data - count=1; - for Sa=0:0.01:5 - MedianSA=(log(Sa)); % Mean of Logarithmic SA Collapse Values - Probability = logncdf(PcollapseSa,MedianSA,SigmaCPS); - Diff(count,1)=abs(Probability-Pcollapse); - count=count+1; - end - [MinErr, indexMin]=min(Diff); - Sa=0:0.01:5; - MedianCPS=Sa(1,indexMin); -end - - -end \ No newline at end of file diff --git a/src/Get_Collapse_Fragility_Parameters.p b/src/Get_Collapse_Fragility_Parameters.p new file mode 100644 index 0000000..ae9895f Binary files /dev/null and b/src/Get_Collapse_Fragility_Parameters.p differ diff --git a/src/Get_Collapse_Loss_Per_IM.m b/src/Get_Collapse_Loss_Per_IM.m deleted file mode 100644 index f46f862..0000000 --- a/src/Get_Collapse_Loss_Per_IM.m +++ /dev/null @@ -1,8 +0,0 @@ -function [COLLAPSE_LOSSES_Per_IM,Pr_Collapse_per_IM]=Get_Collapse_Loss_Per_IM(app,IMpoints,MedianCPS,SigmaCPS,Replacement_Cost) - -app.ProgressText.Value='CALCULATING LOSS DUE TO COLLAPSE'; drawnow; - -Pr_Collapse_per_IM = logncdf(IMpoints,log(MedianCPS),SigmaCPS); % Get the Probability Values of the Collapse Fragility Lognormal Distribution -Pr_Collapse_per_IM = Pr_Collapse_per_IM'; -Pr_Collapse_per_IM(isnan(Pr_Collapse_per_IM))=0; -COLLAPSE_LOSSES_Per_IM = Pr_Collapse_per_IM * Replacement_Cost; % Calculate Collapse Cost diff --git a/src/Get_Collapse_Loss_Per_IM.p b/src/Get_Collapse_Loss_Per_IM.p new file mode 100644 index 0000000..f61cecc Binary files /dev/null and b/src/Get_Collapse_Loss_Per_IM.p differ diff --git a/src/Get_Collapse_Loss_Per_Ri.m b/src/Get_Collapse_Loss_Per_Ri.m deleted file mode 100644 index f85890d..0000000 --- a/src/Get_Collapse_Loss_Per_Ri.m +++ /dev/null @@ -1,41 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% This function queries collapse occurance based on Monte Carlo simulation -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -function [COLLAPSE_LOSSES_Per_Ri] = Get_Collapse_Loss_Per_Ri(app, CPS_Option,IMpoints,MedianCPS,SigmaCPS,nRealization,nStripe,Demolition_Cost,Replacement_Cost,TargetIM) - -app.ProgressText.Value='CALCULATING LOSS DUE TO COLLAPSE'; drawnow; - -% Get the Probability Vector of the Lognormal Collapse Fragility Distribution -nIMpoints=length(IMpoints); -Pr_Collapse_per_IM = logncdf(IMpoints,log(MedianCPS),SigmaCPS); -Pr_Collapse_per_IM = Pr_Collapse_per_IM'; -Pr_Collapse_per_IM(isnan(Pr_Collapse_per_IM))=0; - -COLLAPSE_LOSSES_Per_Ri=zeros(nRealization,nStripe); -if CPS_Option~=0 % If Collapse event is considered - for im=1:nStripe % Loop over analysis stripes - - for ii=1:nIMpoints-1 % Loop over IM levels - if TargetIM(1,im)>=IMpoints(1,ii) && TargetIM(1,im)= min(TargetIM) && IMpoints(1,im)<= max(TargetIM) - if Demolition_Option==1 - Pr_Demolition_per_IM(im,1) = 0.0; - elseif Demolition_Option==2 % i.e., No Demolition OR RDR-Based Demolition - CDF_RDR_Demand = logncdf(RANGE.RDR,log(MEDIAN_IM.RDR(im,1)),SIGMA_IM.RDR(im,1)); - PDF_RDR_Demand = abs(diff(CDF_RDR_Demand)); - Pr_Demolition_per_IM(im,1) = CDF_Demolition * PDF_RDR_Demand'; - elseif Demolition_Option==3 - [CDF_Demolition_Demand, PDF_Demolition_Demand] = Get_CorrBivariateDemolitionCDF(MIDPTS.RDR,MIDPTS.VRD,MEDIAN_IM.RDR(im,1),SIGMA_IM.RDR(im,1),MEDIAN_IM.VRD(im,1),SIGMA_IM.VRD(im,1),Correlation(im,1)); - - Pr_Demolition=0; - for x=1:size(CDF_Demolition_Capacity,1) - for y=1:size(CDF_Demolition_Capacity,2) - Pr_Demolition = Pr_Demolition+ PDF_Demolition_Demand(x,y) * CDF_Demolition_Capacity(x,y); - end - end - Pr_Demolition_per_IM(im,1)=Pr_Demolition; - end - end - -end - -app.ProgressBar.Position=[9 5 613 6]; drawnow ; - -Pr_Demolition_Net_per_IM = Pr_Demolition_per_IM.* (1-Pr_Collapse_per_IM); -DEMOLITION_LOSSES_Per_IM = Pr_Demolition_Net_per_IM * (Demolition_Cost+Replacement_Cost); % Calculate Demolition Cost - diff --git a/src/Get_Demolition_Loss_Per_IM_IDA.p b/src/Get_Demolition_Loss_Per_IM_IDA.p new file mode 100644 index 0000000..ab180b8 Binary files /dev/null and b/src/Get_Demolition_Loss_Per_IM_IDA.p differ diff --git a/src/Get_Demolition_Loss_Per_Ri.m b/src/Get_Demolition_Loss_Per_Ri.m deleted file mode 100644 index 69e417c..0000000 --- a/src/Get_Demolition_Loss_Per_Ri.m +++ /dev/null @@ -1,66 +0,0 @@ -function [DEMOLITION_LOSSES_Per_Ri] = Get_Demolition_Loss_Per_Ri(app,Demolition_Option,nRealization,nStripe,RANGE,DemolishMedianRDR,DemolishSigmaRDR,DemolishMedianVRD,DemolishSigmaVRD,DemolishCorr,REALIZATIONS,Demolition_Cost,Replacement_Cost,COLLAPSE_LOSSES_Per_Ri) - -app.ProgressText.Value='CALCULATING DEMOLITION LOSS DUE TO RESIDUAL DEFORMATIONS'; drawnow - - MIDPTS.RDR=RANGE.RDR(1:end-1)+diff(RANGE.RDR)/2; -if Demolition_Option==3; MIDPTS.VRD=RANGE.VRD(1:end-1)+diff(RANGE.VRD)/2; else; MIDPTS.VRD=0; end - -% Get the CDF of the Demolition Fragility -if Demolition_Option==2 - CDF_Demolition = logncdf(MIDPTS.RDR,log(DemolishMedianRDR),DemolishSigmaRDR); - CDF_Demolition = CDF_Demolition'; -elseif Demolition_Option==3 - [CDF_Demolition, PDF_Demolition] = Get_CorrBivariateDemolitionCDF(MIDPTS.RDR,MIDPTS.VRD,DemolishMedianRDR,DemolishSigmaRDR,DemolishMedianVRD,DemolishSigmaVRD,DemolishCorr); -end - -DEMOLITION_LOSSES_Per_Ri = zeros(nRealization,nStripe); - -if Demolition_Option~=1 - for im=1:nStripe % Loop over IM levels - for Ri=1:nRealization % Loop over realizations - - if Demolition_Option==1 - Pr_Demolition_per_Ri(Ri,im)=0.0; - elseif Demolition_Option==2 - indxRDR=length(MIDPTS.RDR); - for k=1:length(MIDPTS.RDR) - if nStripe==1; rdrRi=REALIZATIONS.RDR(Ri,1); else; evalc(['rdrRi=REALIZATIONS.RDR_S',num2str(im),'(Ri,1)']); end - if rdrRi<=MIDPTS.RDR(k) - indxRDR=k; - break - end - end - evalc(['Pr_Demolition_per_Ri(Ri,im)=CDF_Demolition(indxRDR,1)']); - elseif Demolition_Option==3 - indxRDR=length(MIDPTS.RDR); - indxVRD=length(MIDPTS.VRD); - - for k=1:length(MIDPTS.RDR) - if nStripe==1; rdrRi=REALIZATIONS.RDR(Ri,1); else; evalc(['rdrRi=REALIZATIONS.RDR_S',num2str(im),'(Ri,1)']); end - if rdrRi<=MIDPTS.RDR(k) - indxRDR=k; - break - end - end - for k=1:length(MIDPTS.VRD) - if nStripe==1; vrdRi=REALIZATIONS.VRD(Ri,1); else; evalc(['vrdRi=REALIZATIONS.VRD_S',num2str(im),'(Ri,1)']); end - if vrdRi<=MIDPTS.VRD(k) - indxVRD=k; - break - end - end - evalc(['Pr_Demolition_per_Ri(Ri,im)=CDF_Demolition(indxRDR,indxVRD)']); - end - - RndVar_P_Demolition=randi(100)/100; - if RndVar_P_Demolition<=Pr_Demolition_per_Ri(Ri,im) - DEMOLITION_LOSSES_Per_Ri(Ri,im)=1 * (Demolition_Cost+Replacement_Cost)* (1-COLLAPSE_LOSSES_Per_Ri(Ri,im)/(Demolition_Cost+Replacement_Cost)); - else - DEMOLITION_LOSSES_Per_Ri(Ri,im)=0; - end - end - - app.ProgressText.Value=['CALCULATING DEMOLITION LOSS AT STRIPE #',num2str(im)]; app.ProgressBar.Position=[9 5 im/nStripe*613 6]; drawnow; - - end -end \ No newline at end of file diff --git a/src/Get_Demolition_Loss_Per_Ri.p b/src/Get_Demolition_Loss_Per_Ri.p new file mode 100644 index 0000000..ea17ff8 Binary files /dev/null and b/src/Get_Demolition_Loss_Per_Ri.p differ diff --git a/src/Get_EDP_Data_MultiStripesOption.m b/src/Get_EDP_Data_MultiStripesOption.m deleted file mode 100644 index 27ed656..0000000 --- a/src/Get_EDP_Data_MultiStripesOption.m +++ /dev/null @@ -1,34 +0,0 @@ -function [EDP_Data,MaxSDR,MaxPFA,MaxVRD]=Get_EDP_Data_MultiStripesOption(NRHADataFilePath,NRHADataExcelFileName,Data_Status,N_GM,nStripe) - -cd (NRHADataFilePath); - -% Read EDP data from Excel -for i=1:nStripe - xx = xlsread(NRHADataExcelFileName,['SDR_',num2str(i)] ,'B3:EZ300'); evalc(['EDP_Data.SDR.S', num2str(i),'=xx']); evalc(['EDP_Data.SDRmedian.S', num2str(i),'=median(EDP_Data.SDR.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.SDRsigma.S', num2str(i),'=std(log(EDP_Data.SDR.S', num2str(i),'(1:N_GM,:)))']); - xx = xlsread(NRHADataExcelFileName,['PFA_',num2str(i)] ,'B3:EZ300'); evalc(['EDP_Data.PFA.S', num2str(i),'=xx']); evalc(['EDP_Data.PFAmedian.S', num2str(i),'=median(EDP_Data.PFA.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.PFAsigma.S', num2str(i),'=std(log(EDP_Data.PFA.S', num2str(i),'(1:N_GM,:)))']); - if Data_Status.RDR==1; xx = xlsread(NRHADataExcelFileName,['RDR_',num2str(i)] ,'B3:B300'); evalc(['EDP_Data.RDR.S', num2str(i),'=xx']); evalc(['EDP_Data.RDRmedian.S', num2str(i),'=median(EDP_Data.RDR.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.RDRsigma.S', num2str(i),'=std(log(EDP_Data.RDR.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.VRD==1; xx = xlsread(NRHADataExcelFileName,['VRD_',num2str(i)] ,'B3:B300'); evalc(['EDP_Data.VRD.S', num2str(i),'=xx']); evalc(['EDP_Data.VRDmedian.S', num2str(i),'=median(EDP_Data.VRD.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.VRDsigma.S', num2str(i),'=std(log(EDP_Data.VRD.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.LINKROT==1; xx = xlsread(NRHADataExcelFileName,['LINK ROT_',num2str(i)],'B3:EZ300'); evalc(['EDP_Data.LINKROT.S', num2str(i),'=xx']); evalc(['EDP_Data.LINKROTmedian.S', num2str(i),'=median(EDP_Data.LINKROT.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.LINKROTsigma.S', num2str(i),'=std(log(EDP_Data.LINKROT.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.COLROT==1; xx = xlsread(NRHADataExcelFileName,['COL ROT_', num2str(i)],'B3:EZ300'); evalc(['EDP_Data.COLROT.S', num2str(i),'=xx']); evalc(['EDP_Data.COLROTmedian.S', num2str(i),'=median(EDP_Data.COLROT.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.COLROTsigma.S', num2str(i),'=std(log(EDP_Data.COLROT.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.BEAMROT==1; xx = xlsread(NRHADataExcelFileName,['BEAM ROT_',num2str(i)],'B3:EZ300'); evalc(['EDP_Data.BEAMROT.S', num2str(i),'=xx']); evalc(['EDP_Data.BEAMROTmedian.S', num2str(i),'=median(EDP_Data.BEAMROT.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.BEAMROTsigma.S', num2str(i),'=std(log(EDP_Data.BEAMROT.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.DWD==1; xx = xlsread(NRHADataExcelFileName,['DWD_', num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.DWD.S', num2str(i),'=xx']); evalc(['EDP_Data.DWDmedian.S', num2str(i),'=median(EDP_Data.DWD.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.DWDsigma.S', num2str(i),'=std(log(EDP_Data.DWD.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.RD==1; xx = xlsread(NRHADataExcelFileName,['RD_', num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.RD.S', num2str(i),'=xx']); evalc(['EDP_Data.RDmedian.S', num2str(i),'=median(EDP_Data.RD.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.RDsigma.S', num2str(i),'=std(log(EDP_Data.RD.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENS1==1; xx = xlsread(NRHADataExcelFileName,['GENS1_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENS1.S', num2str(i),'=xx']); evalc(['EDP_Data.GENS1median.S', num2str(i),'=median(EDP_Data.GENS1.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENS1sigma.S', num2str(i),'=std(log(EDP_Data.GENS1.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENS2==1; xx = xlsread(NRHADataExcelFileName,['GENS2_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENS2.S', num2str(i),'=xx']); evalc(['EDP_Data.GENS2median.S', num2str(i),'=median(EDP_Data.GENS2.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENS2sigma.S', num2str(i),'=std(log(EDP_Data.GENS2.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENS3==1; xx = xlsread(NRHADataExcelFileName,['GENS3_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENS3.S', num2str(i),'=xx']); evalc(['EDP_Data.GENS3median.S', num2str(i),'=median(EDP_Data.GENS3.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENS3sigma.S', num2str(i),'=std(log(EDP_Data.GENS3.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENF1==1; xx = xlsread(NRHADataExcelFileName,['GENF1_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENF1.S', num2str(i),'=xx']); evalc(['EDP_Data.GENF1median.S', num2str(i),'=median(EDP_Data.GENF1.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENF1sigma.S', num2str(i),'=std(log(EDP_Data.GENF1.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENF2==1; xx = xlsread(NRHADataExcelFileName,['GENF2_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENF2.S', num2str(i),'=xx']); evalc(['EDP_Data.GENF2median.S', num2str(i),'=median(EDP_Data.GENF2.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENF2sigma.S', num2str(i),'=std(log(EDP_Data.GENF2.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.GENF3==1; xx = xlsread(NRHADataExcelFileName,['GENF3_',num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.GENF3.S', num2str(i),'=xx']); evalc(['EDP_Data.GENF3median.S', num2str(i),'=median(EDP_Data.GENF3.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.GENF3sigma.S', num2str(i),'=std(log(EDP_Data.GENF3.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.PFV==1; xx = xlsread(NRHADataExcelFileName,['PFV_', num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.PFV.S', num2str(i),'=xx']); evalc(['EDP_Data.PFVmedian.S', num2str(i),'=median(EDP_Data.PFV.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.PFVsigma.S', num2str(i),'=std(log(EDP_Data.PFV.S', num2str(i),'(1:N_GM,:)))']); end - if Data_Status.ED==1; xx = xlsread(NRHADataExcelFileName,['ED_', num2str(i)], 'B3:EZ300'); evalc(['EDP_Data.ED.S', num2str(i),'=xx']); evalc(['EDP_Data.EDmedian.S', num2str(i),'=median(EDP_Data.ED.S', num2str(i),'(1:N_GM,:))']); evalc(['EDP_Data.EDsigma.S', num2str(i),'=std(log(EDP_Data.ED.S', num2str(i),'(1:N_GM,:)))']); end -end - - -evalc(['MaxSDR=max(max(EDP_Data.SDRmedian.S',num2str(nStripe),'))']); -evalc(['MaxPFA=max(max(EDP_Data.PFAmedian.S',num2str(nStripe),'))']); -MaxVRD=0; -if Data_Status.VRD==1 - evalc(['MaxVRD=max(max(EDP_Data.VRDmedian.S',num2str(nStripe),'))']); -end - -end \ No newline at end of file diff --git a/src/Get_EDP_Data_MultiStripesOption.p b/src/Get_EDP_Data_MultiStripesOption.p new file mode 100644 index 0000000..349a67e Binary files /dev/null and b/src/Get_EDP_Data_MultiStripesOption.p differ diff --git a/src/Get_EDP_Data_MultipleGMOption.m b/src/Get_EDP_Data_MultipleGMOption.m deleted file mode 100644 index f0a4cc2..0000000 --- a/src/Get_EDP_Data_MultipleGMOption.m +++ /dev/null @@ -1,130 +0,0 @@ -function [EDP_Data,MaxSDR,MaxPFA,MaxVRD]=Get_EDP_Data_MultipleGMOption(NRHADataFilePath,NRHADataExcelFileName,Data_Status,N_GM,nStripe,EDP_Data) - -cd (NRHADataFilePath); - -% Read EDP data from Excel -for i=1:nStripe - xx = xlsread(NRHADataExcelFileName,'SDR' ,'B3:EZ300'); evalc(['EDP_Data.SDR.S',num2str(i),'=xx']); - xx = xlsread(NRHADataExcelFileName,'PFA' ,'B3:EZ300'); evalc(['EDP_Data.PFA.S',num2str(i),'=xx']); - if Data_Status.RDR==1; xx = xlsread(NRHADataExcelFileName,'RDR' ,'B3:B300'); evalc(['EDP_Data.RDR.S',num2str(i),'=xx']); end - if Data_Status.VRD==1; xx = xlsread(NRHADataExcelFileName,'VRD' ,'B3:B300'); evalc(['EDP_Data.VRD.S',num2str(i),'=xx']); end - if Data_Status.LINKROT==1; xx = xlsread(NRHADataExcelFileName,'LINK ROT','B3:EZ300'); evalc(['EDP_Data.LINKROT.S',num2str(i),'=xx']);end - if Data_Status.COLROT==1; xx = xlsread(NRHADataExcelFileName,'COL ROT', 'B3:EZ300'); evalc(['EDP_Data.COLROT.S', num2str(i),'=xx']);end - if Data_Status.BEAMROT==1; xx = xlsread(NRHADataExcelFileName,'BEAM ROT','B3:EZ300'); evalc(['EDP_Data.BEAMROT.S',num2str(i),'=xx']);end - if Data_Status.DWD==1; xx = xlsread(NRHADataExcelFileName,'DWD', 'B3:EZ300'); evalc(['EDP_Data.DWD.S', num2str(i),'=xx']); end - if Data_Status.RD==1; xx = xlsread(NRHADataExcelFileName,'RD', 'B3:EZ300'); evalc(['EDP_Data.RD.S', num2str(i),'=xx']); end - if Data_Status.GENS1==1; xx = xlsread(NRHADataExcelFileName,'GENS1', 'B3:EZ300'); evalc(['EDP_Data.GENS1.S',num2str(i),'=xx']); end - if Data_Status.GENS2==1; xx = xlsread(NRHADataExcelFileName,'GENS2', 'B3:EZ300'); evalc(['EDP_Data.GENS2.S',num2str(i),'=xx']); end - if Data_Status.GENS3==1; xx = xlsread(NRHADataExcelFileName,'GENS3', 'B3:EZ300'); evalc(['EDP_Data.GENS3.S',num2str(i),'=xx']); end - if Data_Status.GENF1==1; xx = xlsread(NRHADataExcelFileName,'GENF1', 'B3:EZ300'); evalc(['EDP_Data.GENF1.S',num2str(i),'=xx']); end - if Data_Status.GENF2==1; xx = xlsread(NRHADataExcelFileName,'GENF2', 'B3:EZ300'); evalc(['EDP_Data.GENF2.S',num2str(i),'=xx']); end - if Data_Status.GENF3==1; xx = xlsread(NRHADataExcelFileName,'GENF3', 'B3:EZ300'); evalc(['EDP_Data.GENF3.S',num2str(i),'=xx']); end - if Data_Status.PFV==1; xx = xlsread(NRHADataExcelFileName,'PFV', 'B3:EZ300'); evalc(['EDP_Data.PFV.S', num2str(i),'=xx']); end - if Data_Status.ED==1; xx = xlsread(NRHADataExcelFileName,'ED', 'B3:EZ300'); evalc(['EDP_Data.ED.S', num2str(i),'=xx']); end -end - -% Get Median and Std of EDPs -EDP_Data.SDRmedian.S1 = median(EDP_Data.SDR.S1(1:N_GM,:)); -EDP_Data.SDRsigma.S1 = std(log(EDP_Data.SDR.S1(1:N_GM,:))); -MaxSDR=max(max(EDP_Data.SDRmedian.S1)); -EDP_Data.SDRcorr=corrcoef (EDP_Data.SDR.S1); - -EDP_Data.PFAmedian.S1 = median(EDP_Data.PFA.S1(1:N_GM,:)); -EDP_Data.PFAsigma.S1 =std(log(EDP_Data.PFA.S1(1:N_GM,:))); -MaxPFA=max(max(EDP_Data.PFAmedian.S1)); -EDP_Data.PFAcorr=corrcoef (EDP_Data.PFA.S1); - -if Data_Status.RDR==1 - EDP_Data.RDRmedian.S1 = median(EDP_Data.RDR.S1(1:N_GM,:)); - EDP_Data.RDRsigma.S1 = std(log(EDP_Data.RDR.S1(1:N_GM,:))); - EDP_Data.RDRcorr=1; -end - -MaxVRD=0; -if Data_Status.VRD==1 - EDP_Data.VRDmedian.S1 = median(EDP_Data.VRD.S1(1:N_GM,:)); - EDP_Data.VRDsigma.S1 = std(log(EDP_Data.VRD.S1(1:N_GM,:))); - MaxVRD = max(max(EDP_Data.VRDmedian.S1)); - EDP_Data.VRDcorr=1; -end - -if Data_Status.LINKROT==1 - EDP_Data.LINKROTmedian.S1 = [0 median(EDP_Data.LINKROT.S1(1:N_GM,:))]; - EDP_Data.LINKROTsigma.S1 = [0 std(log(EDP_Data.LINKROT.S1(1:N_GM,:)))]; - EDP_Data.LINKROTcorr=corrcoef (EDP_Data.LINKROT.S1); -end - -if Data_Status.COLROT==1 - EDP_Data.COLROTmedian.S1 = median(EDP_Data.COLROT.S1(1:N_GM,:)); - EDP_Data.COLROTsigma.S1 = std(log(EDP_Data.COLROT.S1(1:N_GM,:))); - EDP_Data.COLROTcorr=corrcoef (EDP_Data.COLROT.S1); -end - -if Data_Status.BEAMROT==1 - EDP_Data.BEAMROTmedian.S1 = [0 median(EDP_Data.BEAMROT.S1(1:N_GM,:))]; - EDP_Data.BEAMROTsigma.S1 = [0 std(log(EDP_Data.BEAMROT.S1(1:N_GM,:)))]; - EDP_Data.BEAMROTcorr=corrcoef (EDP_Data.BEAMROT.S1); -end - -if Data_Status.DWD==1 - EDP_Data.DWDmedian.S1 = median(EDP_Data.DWD.S1(1:N_GM,:)); - EDP_Data.DWDsigma.S1 = std(log(EDP_Data.DWD.S1(1:N_GM,:))); - EDP_Data.DWDcorr=corrcoef (EDP_Data.DWD.S1); -end - -if Data_Status.RD==1 - EDP_Data.RDmedian.S1 = median(EDP_Data.RD.S1(1:N_GM,:)); - EDP_Data.RDsigma.S1 = std(log(EDP_Data.RD.S1(1:N_GM,:))); - EDP_Data.RDcorr=corrcoef (EDP_Data.RD.S1); -end - -if Data_Status.GENS1==1 - EDP_Data.GENS1median.S1 = median(EDP_Data.GENS1.S1(1:N_GM,:)); - EDP_Data.GENS1sigma.S1 = std(log(EDP_Data.GENS1.S1(1:N_GM,:))); - EDP_Data.GENS1corr=corrcoef (EDP_Data.GENS1.S1); -end - -if Data_Status.GENS2==1 - EDP_Data.GENS2median.S1 = median(EDP_Data.GENS2.S1(1:N_GM,:)); - EDP_Data.GENS2sigma.S1 = std(log(EDP_Data.GENS2.S1(1:N_GM,:))); - EDP_Data.GENS2corr=corrcoef (EDP_Data.GENS2.S1); -end - -if Data_Status.GENS3==1 - EDP_Data.GENS3median.S1 = median(EDP_Data.GENS3.S1(1:N_GM,:)); - EDP_Data.GENS3sigma.S1 = std(log(EDP_Data.GENS3.S1(1:N_GM,:))); - EDP_Data.GENS3corr=corrcoef (EDP_Data.GENS3.S1); -end - -if Data_Status.GENF1==1 - EDP_Data.GENF1median.S1 = median(EDP_Data.GENF1.S1(1:N_GM,:)); - EDP_Data.GENF1sigma.S1 = std(log(EDP_Data.GENF1.S1(1:N_GM,:))); - EDP_Data.GENF1corr=corrcoef (EDP_Data.GENF1.S1); -end - -if Data_Status.GENF2==1 - EDP_Data.GENF2median.S1 = median(EDP_Data.GENF2.S1(1:N_GM,:)); - EDP_Data.GENF2sigma.S1 = std(log(EDP_Data.GENF2.S1(1:N_GM,:))); - EDP_Data.GENF2corr=corrcoef (EDP_Data.GENF2.S1); -end - -if Data_Status.GENF3==1 - EDP_Data.GENF3median.S1 = median(EDP_Data.GENF3.S1(1:N_GM,:)); - EDP_Data.GENF3sigma.S1 = std(log(EDP_Data.GENF3.S1(1:N_GM,:))); - EDP_Data.GENF3corr=corrcoef (EDP_Data.GENF3.S1); -end - -if Data_Status.PFV==1 - EDP_Data.PFVmedian.S1 = median(EDP_Data.PFV.S1(1:N_GM,:)); - EDP_Data.PFVsigma.S1 = std(log(EDP_Data.PFV.S1(1:N_GM,:))); - MaxPFV=max(max(EDP_Data.PFVmedian.S1)); - EDP_Data.PFVcorr=corrcoef (EDP_Data.PFV.S1); -end - -if Data_Status.ED==1 - EDP_Data.EDmedian.S1 = median(EDP_Data.ED.S1(1:N_GM,:)); - EDP_Data.EDsigma.S1 = std(log(EDP_Data.ED.S1(1:N_GM,:))); - EDP_Data.ED=corrcoef (EDP_Data.ED.S1); -end - -end \ No newline at end of file diff --git a/src/Get_EDP_Data_MultipleGMOption.p b/src/Get_EDP_Data_MultipleGMOption.p new file mode 100644 index 0000000..85318d3 Binary files /dev/null and b/src/Get_EDP_Data_MultipleGMOption.p differ diff --git a/src/Get_EDP_Data_ParametersOption.m b/src/Get_EDP_Data_ParametersOption.m deleted file mode 100644 index e8eff72..0000000 --- a/src/Get_EDP_Data_ParametersOption.m +++ /dev/null @@ -1,282 +0,0 @@ -function [EDP_Data,MaxSDR,MaxPFA,MaxVRD]=Get_EDP_Data_ParametersOption(N_Story,NRHADataFilePath,NRHADataExcelFileName,Data_Status,EDP_Data) - -cd (NRHADataFilePath); - -% Read EDP data from Excel -EDP_Data.SDR.S1 = xlsread(NRHADataExcelFileName,'SDR','B3:EZ4'); -EDP_Data.SDRmedian.S1 (1,:) = EDP_Data.SDR.S1(1,:); -EDP_Data.SDRsigma.S1 (1,:) = EDP_Data.SDR.S1(2,:); -Corr = xlsread(NRHADataExcelFileName,'SDR','C9:EZ58'); -Corr(isnan(Corr))=0.0; -Corr2 = rot90(fliplr(Corr),1); -Corr =Corr+Corr2; -Corr(Corr==2)=1; -try chol(Corr); -catch ME - errordlg('Correlation matrix for SDR is not symmetric positive definite! Revise the values in the EXCEL file'); - return -end -EDP_Data.SDRcorr=Corr; -MaxSDR=max(EDP_Data.SDRmedian.S1); - -EDP_Data.PFA.S1 = xlsread(NRHADataExcelFileName,'PFA','B3:EZ4'); -EDP_Data.PFAmedian.S1 (1,:) = EDP_Data.PFA.S1(1,:); -EDP_Data.PFAsigma.S1 (1,:) = EDP_Data.PFA.S1(2,:); -Corr = xlsread(NRHADataExcelFileName,'PFA','C9:EZ58'); -Corr(isnan(Corr))=0.0; -Corr2 = rot90(fliplr(Corr),1); -Corr =Corr+Corr2; -Corr(Corr==2)=1; -try chol(Corr); -catch ME - errordlg('Correlation matrix for PFA is not symmetric positive definite! Revise the values in the EXCEL file'); - return -end -EDP_Data.PFAcorr=Corr; -MaxPFA=max(EDP_Data.PFAmedian.S1); - -% Data Checks -if N_Story ~= size(EDP_Data.SDR.S1,2) || N_Story ~= size(EDP_Data.PFA.S1,2)-1 - errordlg('Excel sheet data size does not agree with number of stories/floors'); - return -end - -if Data_Status.RDR==1 - EDP_Data.RDR.S1 = xlsread(NRHADataExcelFileName,'RDR','B3:EZ4'); - EDP_Data.RDRmedian.S1 (1,:) = EDP_Data.RDR.S1(1,:); - EDP_Data.RDRsigma.S1 (1,:) = EDP_Data.RDR.S1(2,:); - EDP_Data.RDRcorr=1.0; -end - -MaxVRD=0; -if Data_Status.VRD==1 - EDP_Data.VRD.S1 = xlsread(NRHADataExcelFileName,'VRD','B3:C4'); - EDP_Data.VRDmedian.S1 (1,:) = EDP_Data.VRD.S1(1,:); - EDP_Data.VRDsigma.S1 (1,:) = EDP_Data.VRD.S1(2,:); - MaxVRD=max(EDP_Data.VRDmedian.S1); - EDP_Data.VRDcorr=1.0; -end - -if Data_Status.LINKROT==1 - EDP_Data.LINKROT.S1= xlsread(NRHADataExcelFileName,'LINK ROT','B3:EZ4'); - EDP_Data.LINKROTmedian.S1(1,2:N_Story+1)=EDP_Data.LINKROT.S1(1,:); - EDP_Data.LINKROTsigma.S1 (1,2:N_Story+1)=EDP_Data.LINKROT.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'LINK ROT','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for LINK ROT is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.LINKROTcorr=Corr; -end - -if Data_Status.COLROT==1 - EDP_Data.COLROT_S1 = xlsread(NRHADataExcelFileName,'COL ROT','B3:EZ4'); - EDP_Data.COLROTmedian.S1 (1,:)=EDP_Data.COLROT.S1(1,:); - EDP_Data.COLROTsigma.S1 (1,:)=EDP_Data.COLROT.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'COL ROT','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for COL ROT is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.COLROTcorr=Corr; -end - -if Data_Status.BEAMROT==1 - EDP_Data.BEAMROT.S1 = xlsread(NRHADataExcelFileName,'BEAM ROT','B3:EZ4'); - EDP_Data.BEAMROTmedian.S1 (1,2:N_Story+1)=EDP_Data.BEAMROT.S1(1,:); - EDP_Data.BEAMROTsigma.S1 (1,2:N_Story+1)=EDP_Data.BEAMROT.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'BEAM ROT','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for BEAM ROT is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.BEAMROTcorr=Corr; -end - -if Data_Status.DWD==1 - EDP_Data.DWD.S1 = xlsread(NRHADataExcelFileName,'DWD','B3:EZ4'); - EDP_Data.DWDmedian.S1 (1,:)=EDP_Data.DWD.S1(1,:); - EDP_Data.DWDsigma.S1 (1,:)=EDP_Data.DWD.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'DWD','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for DWD is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.DWDcorr=Corr; -end - -if Data_Status.RD==1 - EDP_Data.RD.S1 = xlsread(NRHADataExcelFileName,'RD','B3:EZ4'); - EDP_Data.RDmedian.S1 (1,:)=EDP_Data.RD.S1(1,:); - EDP_Data.RDsigma.S1 (1,:)=EDP_Data.RD.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'RD','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for RD is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.RDcorr=Corr; -end - -if Data_Status.ED==1 - EDP_Data.ED.S1 = xlsread(NRHADataExcelFileName,'ED','B3:EZ4'); - EDP_Data.EDmedian.S1 (1,:)=EDP_Data.ED.S1(1,:); - EDP_Data.EDsigma.S1 (1,:)=EDP_Data.ED.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'ED','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for ED is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.EDcorr=Corr; -end - -if Data_Status.PFV==1 - EDP_Data.PFV.S1 = xlsread(NRHADataExcelFileName,'PFV','B3:EZ4'); - EDP_Data.PFVmedian.S1 (1,:) = EDP_Data.PFV.S1(1,:); - EDP_Data.PFVsigma.S1 (1,:) = EDP_Data.PFV.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'PFV','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for PFV is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.PFVcorr=Corr; -end - -if Data_Status.GENS1==1 - EDP_Data.GENS1.S1 = xlsread(NRHADataExcelFileName,'GENS1','B3:EZ4'); - EDP_Data.GENS1median.S1 (1,:)=EDP_Data.GENS1.S1(1,:); - EDP_Data.GENS1sigma.S1 (1,:)=EDP_Data.GENS1.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENS1','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENS1 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENS1corr=Corr; -end - -if Data_Status.GENS2==1 - EDP_Data.GENS2.S1 = xlsread(NRHADataExcelFileName,'GENS2','B3:EZ4'); - EDP_Data.GENS2median.S1 (1,:)=EDP_Data.GENS2.S1(1,:); - EDP_Data.GENS2sigma.S1 (1,:)=EDP_Data.GENS2.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENS2','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENS2 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENS2corr=Corr; -end - -if Data_Status.GENS3==1 - EDP_Data.GENS3.S1 = xlsread(NRHADataExcelFileName,'GENS3','B3:EZ4'); - EDP_Data.GENS3median.S1 (1,:)=EDP_Data.GENS3.S1(1,:); - EDP_Data.GENS3sigma.S1 (1,:)=EDP_Data.GENS3.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENS3','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENS3 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENS3corr=Corr; -end - -if Data_Status.GENF1==1 - EDP_Data.GENF1.S1 = xlsread(NRHADataExcelFileName,'GENF1','B3:EZ4'); - EDP_Data.GENF1median.S1 (1,2:N_Story+1)=EDP_Data.GENF1.S1(1,:); - EDP_Data.GENF1sigma.S1 (1,2:N_Story+1)=EDP_Data.GENF1.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENF1','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENF1 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENF1corr=Corr; -end - -if Data_Status.GENF2==1 - EDP_Data.GENF2.S1 = xlsread(NRHADataExcelFileName,'GENF2','B3:EZ4'); - EDP_Data.GENF2median.S1 (1,2:N_Story+1)=EDP_Data.GENF2.S1(1,:); - EDP_Data.GENF2sigma.S1 (1,2:N_Story+1)=EDP_Data.GENF2.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENF2','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENF2 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENF2corr=Corr; -end - -if Data_Status.GENF3==1 - EDP_Data.GENF3.S1 = xlsread(NRHADataExcelFileName,'GENF3','B3:EZ4'); - EDP_Data.GENF3median.S1 (1,2:N_Story+1)=EDP_Data.GENF3.S1(1,:); - EDP_Data.GENF3sigma.S1 (1,2:N_Story+1)=EDP_Data.GENF3.S1(2,:); - Corr = xlsread(NRHADataExcelFileName,'GENF3','C9:EZ58'); - Corr(isnan(Corr))=0.0; - Corr2 = rot90(fliplr(Corr),1); - Corr =Corr+Corr2; - Corr(Corr==2)=1; - try chol(Corr); - catch ME - errordlg('Correlation matrix for GENF3 is not symmetric positive definite! Revise the values in the EXCEL file'); - return - end - EDP_Data.GENF3corr=Corr; -end - - -end \ No newline at end of file diff --git a/src/Get_EDP_Data_ParametersOption.p b/src/Get_EDP_Data_ParametersOption.p new file mode 100644 index 0000000..63edd66 Binary files /dev/null and b/src/Get_EDP_Data_ParametersOption.p differ diff --git a/src/Get_EDP_Fargiltiy_Paramters_at_IM.m b/src/Get_EDP_Fargiltiy_Paramters_at_IM.m deleted file mode 100644 index 8fd25a2..0000000 --- a/src/Get_EDP_Fargiltiy_Paramters_at_IM.m +++ /dev/null @@ -1,171 +0,0 @@ -function [MedianEDP,SigmaEDP]=Get_EDP_Fargiltiy_Paramters_at_IM(app,IMpoints,N_GM,ResponseDataFolderPath,EDP_Type,EDPFilename,N_Story) -global MainDirectory - -app.ProgressText.Value=['DEDUCING ', EDP_Type, ' values at IMs']; - -dirResult = dir(ResponseDataFolderPath); -allDirs = dirResult([dirResult.isdir]); -allSubDirs = allDirs(3:end); - -IMpoints=IMpoints'; -nIMpoints=size(IMpoints,1); - -MedianEDP = zeros(nIMpoints,N_Story); -SigmaEDP = zeros(nIMpoints,N_Story); - -%----------------------------------------------------------------------------------------------------------------------------------------------% -%----------------------------------------------------------------------------------------------------------------------------------------------% -%----------------------------------------------------------------------------------------------------------------------------------------------% -%----------------------------------------------------------------------------------------------------------------------------------------------% - -for GM_No=1:N_GM - % Go in the GM folder and read the results files - thisDir = allSubDirs(GM_No); - thisDirName = thisDir.name; - cd (ResponseDataFolderPath); - cd(num2str(thisDirName)) - - % Read IDA Data File - IDA_Data = importdata(EDPFilename); - cd (MainDirectory); - SA = IDA_Data(:,1); - EDP = IDA_Data(:,2:end); - - if strcmp(EDP_Type,'SDR')==1 || strcmp(EDP_Type,'RDR')==1 || strcmp(EDP_Type,'COL ROT')==1 || strcmp(EDP_Type,'BEAM ROT')==1 || strcmp(EDP_Type,'DWD')==1 || strcmp(EDP_Type,'RD')==1 - SA(end,1)=SA(end,1)+0.001; SA(end+1,1)=SA(end,1)+0.001; EDP(end+1,:)=0.2; - elseif strcmp(EDP_Type,'PFA')==1 - SA(end,1)=SA(end,1)+0.001; SA(end+1,1)=SA(end,1)+0.001; EDP(end+1,:)=max(max(EDP(:,2:end),[] ,2)); - elseif strcmp(EDP_Type,'VRD')==1 - SA(end,1)=SA(end,1)+0.001; - end - - % Remove rows with NaN values - for i=1:size(SA,1) - if isnan(SA(i,1)) || isnan(EDP(i,1)) - SA(i,:)=[]; - EDP(i,:)=[]; - end - end - - % Get the IDA curve for each GM with refined and consistent IM points - SA_Refined=IMpoints; - for Storyi=1:N_Story - EDP_Refined=zeros(size(IMpoints,1),1); - for i=1:size(IMpoints,1) - if IMpoints(i)1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'PFA')==1 - MIDPTS.EDP=MIDPTS.PFA; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); end - elseif strcmp(EDP_Type,'PFV')==1 - MIDPTS.EDP=MIDPTS.PFV; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); end - elseif strcmp(EDP_Type,'PFA')==1 && n==1 - MIDPTS.EDP=MIDPTS.PFA; - PEDP=logncdf(EDP_Range,log(MedianEDP(1,1)),SigmaEDP(1,1)); - elseif strcmp(EDP_Type,'LINK ROT')==1 - MIDPTS.EDP=MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); - elseif strcmp(EDP_Type,'BEAM ROT')==1 - MIDPTS.EDP=MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); - elseif strcmp(EDP_Type,'COL ROT')==1 - MIDPTS.EDP = MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); - elseif strcmp(EDP_Type,'DWD')==1 - MIDPTS.EDP = MIDPTS.SDR; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'RD')==1 - MIDPTS.EDP = MIDPTS.SDR; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'GENS1')==1 - MIDPTS.EDP = MIDPTS.GENS1; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'GENS2')==1 - MIDPTS.EDP = MIDPTS.GENS2; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'GENS3')==1 - MIDPTS.EDP = MIDPTS.GENS3; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n-1)),SigmaEDP(1,n-1)); end - elseif strcmp(EDP_Type,'GENF1')==1 - MIDPTS.EDP=MIDPTS.GENF1; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); end - elseif strcmp(EDP_Type,'GENF2')==1 - MIDPTS.EDP=MIDPTS.GENF2; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); end - elseif strcmp(EDP_Type,'GENF3')==1 - MIDPTS.EDP=MIDPTS.GENF3; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP(1,n)),SigmaEDP(1,n)); end - end - - DPEDP=abs(diff(PEDP));% Probability of occurance of a given EDP (for a specific 1 value) - -end \ No newline at end of file diff --git a/src/Get_EDP_FragParam.p b/src/Get_EDP_FragParam.p new file mode 100644 index 0000000..f1a1556 Binary files /dev/null and b/src/Get_EDP_FragParam.p differ diff --git a/src/Get_EDP_FragParam_IM.m b/src/Get_EDP_FragParam_IM.m deleted file mode 100644 index 5652c19..0000000 --- a/src/Get_EDP_FragParam_IM.m +++ /dev/null @@ -1,131 +0,0 @@ -function [MIDPTS, DPEDP]=Get_EDP_FragParam_IM(FRAGDATA,IDXF,Range,Median_IM,Sigma_IM,MIDPTS,Ci_level,N_Story,n,im) - if strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'SDR')==1 - EDP_Range=Range.SDR; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.SDR; - SigmaEDP_IM=Sigma_IM.SDR; - MIDPTS.EDP=MIDPTS.SDR; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PFA')==1 - EDP_Range=Range.PFA; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.PFA; - SigmaEDP_IM=Sigma_IM.PFA; - MIDPTS.EDP=MIDPTS.PFA; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PGA')==1 - EDP_Range=Range.PFA; - MedianEDP_IM=Median_IM.PFA(:,1); - SigmaEDP_IM=Sigma_IM.PFA(:,1); - MIDPTS.EDP=MIDPTS.PFA; - PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,1)),SigmaEDP_IM(im,1)); - DPEDP=abs(diff(PEDP));% Probability of occurance of a given EDP (for a specific im value) - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PFV')==1 - EDP_Range=Range.PFV; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.PFV; - SigmaEDP_IM=Sigma_IM.PFV; - MIDPTS.EDP=MIDPTS.PFV; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'LINK ROT')==1 - EDP_Range=Range.SDR; - MedianEDP_IM=Median_IM.LINKROT; - SigmaEDP_IM=Sigma_IM.LINKROT; - MIDPTS.EDP=MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'BEAM ROT')==1 - EDP_Range=Range.SDR; - MedianEDP_IM=Median_IM.BEAMROT; - SigmaEDP_IM=Sigma_IM.BEAMROT; - MIDPTS.EDP=MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'COL ROT')==1 - EDP_Range = Range.SDR; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.COLROT; - SigmaEDP_IM = Sigma_IM.COLROT; - MIDPTS.EDP = MIDPTS.SDR; - PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'DWD')==1 - EDP_Range = Range.SDR; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.DWD; - SigmaEDP_IM = Sigma_IM.DWD; - MIDPTS.EDP = MIDPTS.SDR; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'RD')==1 - EDP_Range = Range.SDR; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.RD; - SigmaEDP_IM = Sigma_IM.RD; - MIDPTS.EDP = MIDPTS.SDR; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS1')==1 - EDP_Range = Range.GENS1; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.GENS1; - SigmaEDP_IM = Sigma_IM.GENS1; - MIDPTS.EDP = MIDPTS.GENS1; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS2')==1 - EDP_Range = Range.GENS2; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.GENS2; - SigmaEDP_IM = Sigma_IM.GENS2; - MIDPTS.EDP = MIDPTS.GENS2; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS3')==1 - EDP_Range = Range.GENS3; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM = Median_IM.GENS3; - SigmaEDP_IM = Sigma_IM.GENS3; - MIDPTS.EDP = MIDPTS.GENS3; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n-1)),SigmaEDP_IM(im,n-1)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF1')==1 - EDP_Range=Range.GENF1; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.GENF1; - SigmaEDP_IM=Sigma_IM.GENF1; - MIDPTS.EDP=MIDPTS.GENF1; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF2')==1 - EDP_Range=Range.GENF2; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.GENF2; - SigmaEDP_IM=Sigma_IM.GENF2; - MIDPTS.EDP=MIDPTS.GENF2; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); end - DPEDP=abs(diff(PEDP)); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF3')==1 - EDP_Range=Range.GENF3; - PEDP=zeros(1,length(EDP_Range)); - MedianEDP_IM=Median_IM.GENF3; - SigmaEDP_IM=Sigma_IM.GENF3; - MIDPTS.EDP=MIDPTS.GENF3; - if Ci_level==1 && n1; PEDP=logncdf(EDP_Range,log(MedianEDP_IM(im,n)),SigmaEDP_IM(im,n)); end - DPEDP=abs(diff(PEDP)); - end -end \ No newline at end of file diff --git a/src/Get_EDP_FragParam_IM.p b/src/Get_EDP_FragParam_IM.p new file mode 100644 index 0000000..9f3f8b5 Binary files /dev/null and b/src/Get_EDP_FragParam_IM.p differ diff --git a/src/Get_EDP_Range.m b/src/Get_EDP_Range.m deleted file mode 100644 index 29bcaa5..0000000 --- a/src/Get_EDP_Range.m +++ /dev/null @@ -1,28 +0,0 @@ -function [MaxEDP]=Get_EDP_Range(N_GM,MainDirectory,ResponseDataFolderPath,EDPFilename) -global MainDirectory - - -dirResult = dir(ResponseDataFolderPath); -allDirs = dirResult([dirResult.isdir]); -allSubDirs = allDirs(3:end); - -for GM_No=1:N_GM - % Go in the GM folder and read the results files - thisDir = allSubDirs(GM_No); - thisDirName = thisDir.name; - cd (ResponseDataFolderPath); - cd(num2str(thisDirName)) - - % Read IDA SDR Data File - IDA_Data = importdata(EDPFilename); - cd (MainDirectory); - IDA_Data(end,:)=[]; - EDP = IDA_Data(:,2:end); - - EDPmax(GM_No,1)=max(max(EDP)); - - fclose all; - clear EDP SA -end - -MaxEDP=max(EDPmax); \ No newline at end of file diff --git a/src/Get_EDP_Range.p b/src/Get_EDP_Range.p new file mode 100644 index 0000000..27da1a7 Binary files /dev/null and b/src/Get_EDP_Range.p differ diff --git a/src/Get_HazardCurve_SaAVG.m b/src/Get_HazardCurve_SaAVG.m deleted file mode 100644 index 90614e2..0000000 --- a/src/Get_HazardCurve_SaAVG.m +++ /dev/null @@ -1,45 +0,0 @@ -%% CODE CAN BE USED TO TRANSFORM USGS HAZARD CURVE FROM SA(T1) to SAavg -function [HazardCurveData]= Get_HazardCurve_SaAVG (MainDirectory,HazardFolderPath,Latitude,Longitude,Ti,Vs30,IMpoints); - - -IMpoints=0.001:0.005:3.0; -Latitude=33.996; -Longitude=-118.162; -Vs30=259; -HazardFolderPath='D:\USGS Hazard Data'; -MainDirectory=pwd; -Vs30=259; -T=1.25; - - count=0; -for Ti=0.2*T:0.1:3.0*T - count=count+1; - [HazardCurveData]= Get_HazardCurve_USGSMaps (MainDirectory,HazardFolderPath,Latitude,Longitude,Ti,Vs30,IMpoints); - evalc(strcat(['HazardCurves.T',num2str(count),'=HazardCurveData'])); -end - -nPeriods=count; - -lmbda=[10e-6:10e-6:10e-5 20e-5:10e-5:10e-4 20e-4:10e-4:10e-3 0.02:0.01:0.1 0.2:0.1:1.0]; - - count=0; -for i=1:size(lmbda,2) - - count=count+1; - for n=1:nPeriods - evalc(strcat(['X=HazardCurves.T',num2str(n)])); - SaT1(n,1)=interp1(X(:,2),X(:,1),lmbda(1,i)); - end - - Sa_PRODUCT=1; - for n=1:nPeriods - Sa_PRODUCT=Sa_PRODUCT*SaT1(n,1)^(1/nPeriods); - end - SAavg(count,1)=Sa_PRODUCT; - -end - -figure -plot(SAavg,lmbda); -set(gca, 'XScale', 'log') -set(gca, 'YScale', 'log') \ No newline at end of file diff --git a/src/Get_HazardCurve_SaAVG.p b/src/Get_HazardCurve_SaAVG.p new file mode 100644 index 0000000..0cd0235 Binary files /dev/null and b/src/Get_HazardCurve_SaAVG.p differ diff --git a/src/Get_Project_Summary.m b/src/Get_Project_Summary.m deleted file mode 100644 index 5972817..0000000 --- a/src/Get_Project_Summary.m +++ /dev/null @@ -1,217 +0,0 @@ -function [SummaryText]=Get_Project_Summary -global MainDirectory ProjectPath ProjectName - -clc -cd (ProjectPath); -load(ProjectName) -cd (MainDirectory); - -if Units==2 - massUnit=' kN.sec2/m'; - dispUnit=' m'; - forceUnit=' kN'; - KUnit=' kN/m'; -else - massUnit=' kip.sec2/ft'; - dispUnit=' ft'; - forceUnit=' kip'; - KUnit=' kip/ft'; -end - -i=1; -SummaryText{i}='******************************************************';i=i+1; -SummaryText{i}='******************************************************';i=i+1; -SummaryText{i}=' PROJECT SUMMARY ';i=i+1; -SummaryText{i}='******************************************************';i=i+1; -SummaryText{i}='******************************************************';i=i+1; -SummaryText{i}='';i=i+1; - -if BuildingDataStatus~=1 - SummaryText{i}='NO PROJECT DATA ARE DEFINED YET';i=i+1; -end - -if Units==1 - SummaryText{i}='Units: Imperial';i=i+1; -else - SummaryText{i}='Units: SI';i=i+1; -end -SummaryText{i}='';i=i+1; - -if BuildingDataStatus==1 - SummaryText{i}='BUILDING DESCRIPTION';i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - SummaryText{i}=char(BuildingDescription);i=i+1; - SummaryText{i}='';i=i+1; - SummaryText{i}='BUILDING DATA';i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - SummaryText{i}=['Occupancy: ', OccupancyName];i=i+1; - SummaryText{i}=['Construction Material: ', Material{1,1}, Material{1,2}, Material{1,3}, Material{1,4}];i=i+1; - SummaryText{i}=['System Type: ', System_Type{1,1}];i=i+1; - SummaryText{i}=['No. of Stories: ', num2str(N_Story)];i=i+1; - SummaryText{i}=['Foot Print Area: ', num2str(Area_FootPrint), dispUnit,'2'];i=i+1; - SummaryText{i}=['Total Foot Print Area: ', num2str(Area_Total), dispUnit,'2'];i=i+1; - SummaryText{i}=['Demolition Cost: ', num2str(Demolition_Cost/1000000), 'M$'];i=i+1; - SummaryText{i}=['Replacement Cost: ', num2str(Replacement_Cost/1000000), 'M$'];i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; -end - -SummaryText{i}='';i=i+1; - -if ComponentDataStatus==1 - SummaryText{i}='COMPONENT DEFINITION';i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - if Component_Option==1 - SummaryText{i}=['Defined Components:'];i=i+1; - Unique_Component_Names = unique(Component_Data(:,2)); - for j=1:size(Unique_Component_Names,1) - SummaryText{i}=[' -', Unique_Component_Names{j,1}];i=i+1; - end - elseif Component_Option==2 - SummaryText{i}=['Loss-EDP Functions by Papadopoulos et al (2018)'];i=i+1; - SummaryText{i}=['Structural System: ', StructuralSystemName];i=i+1; - SummaryText{i}=['Luxury Level: ', Luxury_Level_Name];i=i+1; - elseif Component_Option==3 - SummaryText{i}=['Loss-EDP Functions by Ramirez & Miranda (2009)'];i=i+1; - if FrameType==1; SummaryText{i}=['Frame Type: Perimeter Frame'];i=i+1; end - if FrameType==2; SummaryText{i}=['Frame Type: Space Frame'];i=i+1; end - if DuctilityType==1; SummaryText{i}=['Ductility: Ductile'];i=i+1; end - if DuctilityType==2; SummaryText{i}=['Ductility: Non-Ductile'];i=i+1; end - end - SummaryText{i}='------------------------------------------------------';i=i+1; -end - -SummaryText{i}='';i=i+1; - -if ResponseDataStatus==1 - SummaryText{i}=['RESPONSE DATA'];i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - if Response_Option==1 - SummaryText{i}='Response Data - IDA Data';i=i+1; - SummaryText{i}=['Response Data Folder Directory: '];i=i+1; - SummaryText{i}=[ResponseDataFolderPath];i=i+1; - elseif Response_Option==2 - SummaryText{i}='Response Data - Single Intensity for Multiple GMs';i=i+1; - SummaryText{i}=['Response Data Excel Filename: ',NRHADataExcelFileName];i=i+1; - SummaryText{i}=['IM level: ',num2str(TargetIM(1,1)), 'g'];i=i+1; - SummaryText{i}=['Number of GMs: ', num2str(N_GM)];i=i+1; - elseif Response_Option==3 - SummaryText{i}='Response Data - Single Intensity (Distribution Parameters)';i=i+1; - SummaryText{i}=['IM level: ', num2str(TargetIM(1,1)), 'g'];i=i+1; - elseif Response_Option==4 - SummaryText{i}='Response Data - Multiple Stripes';i=i+1; - SummaryText{i}=['Response Data Excel Filename: '];i=i+1; - SummaryText{i}=[NRHADataExcelFileName];i=i+1; - SummaryText{i}=['Number of GMs: ',num2str(N_GM)];i=i+1; - SummaryText{i}=['Number of Stripes: ',num2str(nStripe)];i=i+1; - elseif Response_Option==5 - v2struct(Option5Data) - SummaryText{i}='MDoF Shear Model';i=i+1; - if ModelType==1; SummaryText{i}=['System Behavior: Elastic'];i=i+1; end - if ModelType==2; SummaryText{i}=['System Behavior: Bi-Linear'];i=i+1; end - if ModelType==3; SummaryText{i}=['System Behavior: IMK Bilinear'];i=i+1; end - if ModelType==4; SummaryText{i}=['System Behavior: IMK PeakOriented'];i=i+1; end - SummaryText{i}=['System Response Excel Filename: ', char(ExcelFileName)];i=i+1; - SummaryText{i}=['GM Folder Name: ',GMFolderName];i=i+1; - SummaryText{i}=['Number of GMs: ', num2str(N_GM)];i=i+1; - if Option5_Type==1 - SummaryText{i}=['Analysis Type: IDA'];i=i+1; - SummaryText{i}=['Scale Period: ', num2str(T1),'sec'];i=i+1; - SummaryText{i}=['Damping: ', num2str(zeta*100),'%'];i=i+1; - end - if Option5_Type==2 - SummaryText{i}=['Analysis Type: Target GM Scale Factor'];i=i+1; - SummaryText{i}=['Target Scale Factor: ', num2str(SF)];i=i+1; - SummaryText{i}=['Damping: ', num2str(zeta*100),'%'];i=i+1; - end - if Option5_Type==3 - SummaryText{i}=['Analysis Type: Target IM Level'];i=i+1; - SummaryText{i}=['Target IM: ', num2str(TargetIM(1,1)),'g'];i=i+1; - SummaryText{i}=['Scale Period: ', num2str(T1),'sec'];i=i+1; - SummaryText{i}=['Damping: ', num2str(zeta*100),'%'];i=i+1; - end - elseif Response_Option==6 - v2struct(Option6Data) - SummaryText{i}='FEMA P-58 Simplified Analysis Method';i=i+1; - SummaryText{i}=['System Response Excel Filename: ',char(ExcelFileName)];i=i+1; - SummaryText{i}=['T1: ',num2str(T1),'sec'];i=i+1; - SummaryText{i}=['PGA: ',num2str(PGA),'g'];i=i+1; - SummaryText{i}=['Sa(T1): ',num2str(SaT1),'g'];i=i+1; - SummaryText{i}=['Vy: ',num2str(Vy1),forceUnit];i=i+1; - SummaryText{i}=['SDRy: ',num2str(SDRy*100),'% rad'];i=i+1; - end - SummaryText{i}='------------------------------------------------------';i=i+1; -end - -SummaryText{i}='';i=i+1; - -if HazardDataStatus==1 - SummaryText{i}=['SEISMIC HAZARD'];i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - if HazardOption==1 - SummaryText{i}='USGS Hazard Maps';i=i+1; - SummaryText{i}=['Longitude: ',num2str(Longitude), ' degrees'];i=i+1; - SummaryText{i}=['Latitude: ',num2str(Latitude), ' degrees'];i=i+1; - SummaryText{i}=['Period: ',num2str(T1),' sec'];i=i+1; - SummaryText{i}=['Soil Shear Wave Velocity: ',num2str(Vs30),' m/sec'];i=i+1; - SummaryText{i}='------------------------------------------------------';i=i+1; - else - SummaryText{i}='Seismic hazard curve imported by the user';i=i+1; - end -end - -SummaryText{i}='';i=i+1; - -SummaryText{i}=['IM BINS'];i=i+1; -SummaryText{i}='------------------------------------------------------';i=i+1; -SummaryText{i}=['Initial Intensity: ', num2str(IMstart), 'g'];i=i+1; -SummaryText{i}=['Incr. Intensity: ', num2str(IMincr), 'g'];i=i+1; -SummaryText{i}=['Last Intensity: ', num2str(IMend), 'g'];i=i+1; -if TargetIM_Option==1 - SummaryText{i}=['Target Intensity: All Intensity Range'];i=i+1; -elseif TargetIM_Option==2 - SummaryText{i}=['Target Intensity: ', num2str(TargetIMstart), 'g to ',num2str(TargetIMend),'g'];i=i+1; -elseif TargetIM_Option==3 - SummaryText{i}=['Target Intensity: ', num2str(TargetIMstart), 'g'];i=i+1; -end - -SummaryText{i}='';i=i+1; - -SummaryText{i}=['DEMOLITION PARAMETERS'];i=i+1; -SummaryText{i}='------------------------------------------------------';i=i+1; -if Demolition_Option==1 - SummaryText{i}=['Demolition Event is Not Considered'];i=i+1; -end -if Demolition_Option==2 - SummaryText{i}=['Univariate Demolition Fragility'];i=i+1; - SummaryText{i}=['Median RDR: ', num2str(DemolishMedianRDR), ' rad'];i=i+1; - SummaryText{i}=['Sigma ln(RDR): ', num2str(DemolishSigmaRDR)];i=i+1; -end -if Demolition_Option==3 - SummaryText{i}=['Bivariate Demolition Fragility'];i=i+1; - SummaryText{i}=['Median RDR: ', num2str(DemolishMedianRDR), ' rad'];i=i+1; - SummaryText{i}=['Sigma ln(RDR): ', num2str(DemolishSigmaRDR)];i=i+1; - SummaryText{i}=['Median VRD: ', num2str(DemolishMedianVRD), ' mm'];i=i+1; - SummaryText{i}=['Sigma ln(VRD): ', num2str(DemolishSigmaVRD)];i=i+1; - SummaryText{i}=['Correlation: ', num2str(DemolishCorr)];i=i+1; -end - -SummaryText{i}='';i=i+1; - -SummaryText{i}=['COLLAPSE PARAMETERS'];i=i+1; -SummaryText{i}='------------------------------------------------------';i=i+1; -if CPS_Option==0 - SummaryText{i}=['Collapse Event is Not Considered'];i=i+1; -end -if CPS_Option==1 || CPS_Option==2 || CPS_Option==3 - SummaryText{i}=['Univariate Collapse Fragility'];i=i+1; - if CPS_Option==1; SummaryText{i}=['Fragility parameters deduced from IDA data'];i=i+1; end - if CPS_Option==2; SummaryText{i}=['Fragility parameters specified directly'];i=i+1; end - if CPS_Option==3; SummaryText{i}=['Fragility parameters specified indirectly using a point on the curve'];i=i+1; end - SummaryText{i}=['Median IM: ', num2str(MedianCPS), ' g'];i=i+1; - SummaryText{i}=['Sigma : ', num2str(SigmaCPS)];i=i+1; -end - -SummaryText{i}='';i=i+1; - -SummaryText{i}='******************************************************';i=i+1; -SummaryText{i}='******************************************************';i=i+1; diff --git a/src/Get_Project_Summary.p b/src/Get_Project_Summary.p new file mode 100644 index 0000000..c53cd9f Binary files /dev/null and b/src/Get_Project_Summary.p differ diff --git a/src/Get_REALIZATIONS.m b/src/Get_REALIZATIONS.m deleted file mode 100644 index cb6a9a2..0000000 --- a/src/Get_REALIZATIONS.m +++ /dev/null @@ -1,77 +0,0 @@ -function [REALIZATIONS]=Get_REALIZATIONS(app) - -app.ProgressText.Value='GENERATING EDP REALIZATIONS'; app.ProgressBar.BackgroundColor='g'; app.ProgressBar.Position=[9 5 613 6]; drawnow; - -global MainDirectory ProjectPath ProjectName -cd (ProjectPath) -load (ProjectName) -cd (MainDirectory) - - -if Response_Option==4 - - nRealizationx=nRealization-size(EDP_Data.SDR.S1,1); - RndVarVector=0; - for i=1:nRealizationx - RndVarVector1=normrnd(0,1,N_Story+1,1); - RndVarVector=[RndVarVector; RndVarVector1]; - end - RndVarVector(1,:)=[]; - - REALIZATIONS.SDR_S1=0; - for n=1:nStripe - [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'SDR',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); - [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'PFA',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); - if Data_Status.RDR==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'RDR',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.VRD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'VRD',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.LINKROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data,'LINK ROT',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.COLROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'COL ROT',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.BEAMROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data,'BEAM ROT',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.DWD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'DWD',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.RD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'RD',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENS1==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENS1',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENS2==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENS2',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENS3==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENS3',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENF1==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENF1',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENF2==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENF2',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.GENF3==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'GENF3',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.PFV==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'PFV',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - if Data_Status.ED==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_MS(EDP_Data, 'ED',REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd); end - end - -else - - - if Response_Option==2; nRealizationx = nRealization-size(EDP_Data.SDR.S1,1); - else; nRealizationx = nRealization; - end - - RndVarVector=0; - for kk=1:nRealizationx - RndVarVector1=normrnd(0,1,N_Story+1,1); - RndVarVector=[RndVarVector; RndVarVector1]; - end - RndVarVector(1,:)=[]; - - REALIZATIONS.X=0; - for n=1:nStripe - [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'SDR',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); - [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'PFA',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); - if Data_Status.RDR==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'RDR',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.VRD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'VRD',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.LINKROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data,'LINK ROT',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.COLROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'COL ROT',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.BEAMROT==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data,'BEAM ROT',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.DWD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'DWD',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.RD==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'RD',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENS1==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENS1',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENS2==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENS2',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENS3==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENS3',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENF1==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENF1',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENF2==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENF2',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.GENF3==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'GENF3',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.PFV==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'PFV',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - if Data_Status.ED==1; [REALIZATIONS]=Get_REALIZATIONS_Matrix_SI(EDP_Data, 'ED',REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option); end - end - -end \ No newline at end of file diff --git a/src/Get_REALIZATIONS.p b/src/Get_REALIZATIONS.p new file mode 100644 index 0000000..3a8856a Binary files /dev/null and b/src/Get_REALIZATIONS.p differ diff --git a/src/Get_REALIZATIONS_Matrix_MS.m b/src/Get_REALIZATIONS_Matrix_MS.m deleted file mode 100644 index 33d9b87..0000000 --- a/src/Get_REALIZATIONS_Matrix_MS.m +++ /dev/null @@ -1,76 +0,0 @@ -function [REALIZATIONS] = Get_REALIZATIONS_Matrix_MS(EDP_Data,EDP_Type,REALIZATIONS,nRealizationx,RndVarVector,n,N_Story,stdAdd) - - evalc(['X=EDP_Data.',EDP_Type,'.S',num2str(n)]); - size2=size(X,2); - - % Based on Yang et al (2009) - Y=log(X); - My=mean(Y)'; - Dy=diag(sqrt(std(Y).^2+stdAdd^2)); - Ryy=corrcoef(Y); - - try - Ly=chol(Ryy)'; - catch ME - [~,Ly] = lu(Ryy); - Ly=Ly'; - end - - counter=1; - for i=1:nRealizationx - RndVarVectorX=RndVarVector(i:i+size2-1,1); - Z=Dy*Ly*RndVarVectorX+My; - W(counter,:)=exp(Z)'; - counter=counter+1; - end - - if strcmp(EDP_Type,'SDR')==1 - evalc(['REALIZATIONS.SDR_S',num2str(n),'=W']); - evalc(['REALIZATIONS.SDR_S',num2str(n),'=[REALIZATIONS.SDR_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'PFA')==1 - evalc(['REALIZATIONS.PFA_S',num2str(n),'=W']); - evalc(['REALIZATIONS.PFA_S',num2str(n),'=[REALIZATIONS.PFA_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'RDR')==1 - evalc(['REALIZATIONS.RDR_S',num2str(n),'=W']); - evalc(['REALIZATIONS.RDR_S',num2str(n),'=[REALIZATIONS.RDR_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'VRD')==1 - evalc(['REALIZATIONS.VRD_S',num2str(n),'=W']); - evalc(['REALIZATIONS.VRD_S',num2str(n),'=[REALIZATIONS.VRD_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'PGA')==1 - evalc(['REALIZATIONS.PGA_S',num2str(n),'=W']); - evalc(['REALIZATIONS.PGA_S',num2str(n),'=[REALIZATIONS.PGA_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'LINK ROT')==1 - evalc(['REALIZATIONS.LINKROT_S',num2str(n),'=W']); - evalc(['REALIZATIONS.LINKROT_S',num2str(n),'=[REALIZATIONS.LINKROT_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'BEAM ROT')==1 - evalc(['REALIZATIONS.BEAMROT_S',num2str(n),'=W']); - evalc(['REALIZATIONS.BEAMROT_S',num2str(n),'=[REALIZATIONS.BEAMROT_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'COL ROT')==1 - evalc(['REALIZATIONS.COLROT_S',num2str(n),'=W']); - evalc(['REALIZATIONS.COLROT_S',num2str(n),'=[REALIZATIONS.COLROT_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'DWD')==1 - evalc(['REALIZATIONS.DWD_S',num2str(n),'=W']); - evalc(['REALIZATIONS.DWD_S',num2str(n),'=[REALIZATIONS.DWD_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'RD')==1 - evalc(['REALIZATIONS.RD_S',num2str(n),'=W']); - evalc(['REALIZATIONS.RD_S',num2str(n),'=[REALIZATIONS.RD_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENS1')==1 - evalc(['REALIZATIONS.GENS1_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENS1_S',num2str(n),'=[REALIZATIONS.GENS1_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENS2')==1 - evalc(['REALIZATIONS.GENS2_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENS2_S',num2str(n),'=[REALIZATIONS.GENS2_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENS3')==1 - evalc(['REALIZATIONS.GENS3_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENS3_S',num2str(n),'=[REALIZATIONS.GENS3_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENF1')==1 - evalc(['REALIZATIONS.GENF1_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENF1_S',num2str(n),'=[REALIZATIONS.GENF1_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENF2')==1 - evalc(['REALIZATIONS.GENF2_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENF2_S',num2str(n),'=[REALIZATIONS.GENF2_S',num2str(n),'; X]']); - elseif strcmp(EDP_Type,'GENF3')==1 - evalc(['REALIZATIONS.GENF3_S',num2str(n),'=W']); - evalc(['REALIZATIONS.GENF3_S',num2str(n),'=[REALIZATIONS.GENF3_S',num2str(n),'; X]']); - end -end \ No newline at end of file diff --git a/src/Get_REALIZATIONS_Matrix_MS.p b/src/Get_REALIZATIONS_Matrix_MS.p new file mode 100644 index 0000000..7b4e86e Binary files /dev/null and b/src/Get_REALIZATIONS_Matrix_MS.p differ diff --git a/src/Get_REALIZATIONS_Matrix_SI.m b/src/Get_REALIZATIONS_Matrix_SI.m deleted file mode 100644 index 8252476..0000000 --- a/src/Get_REALIZATIONS_Matrix_SI.m +++ /dev/null @@ -1,105 +0,0 @@ -function [REALIZATIONS] = Get_REALIZATIONS_Matrix_SI(EDP_Data,EDP_Type,REALIZATIONS,nRealizationx,RndVarVector,n,stdAdd,Response_Option) - - evalc(['MedianEDP=EDP_Data.',EDP_Type,'median.S',num2str(n)]); - evalc(['SigmaEDP=EDP_Data.',EDP_Type,'sigma.S',num2str(n)]); - evalc(['CorrEDP=EDP_Data.',EDP_Type,'corr']); - - if Response_Option==5 && size(EDP_Data.SDR.S1,1)==1 - Response_Option=10; - end - - if Response_Option==2 || Response_Option==5 - evalc(['X=EDP_Data.',EDP_Type,'.S',num2str(n)]); - size2=size(X,2); - Y=log(X); - My=mean(Y)'; - Dy=diag(sqrt(std(Y).^2+stdAdd^2)); - Ryy=corrcoef(Y); - else - size2=size(MedianEDP,2); - My=log(MedianEDP)'; - Dy=diag(sqrt(SigmaEDP.^2+stdAdd^2)); - Ryy=CorrEDP; - end - - - - try - Ly = chol(Ryy)'; - catch ME - % Fix for highly correlated input data - %Ryy=round(Ryy*1000)/1000; - %Imat=eye(size(Ryy, 1)); - %Xmat=zeros(size(Ryy, 1))+0.99; - %Ryy=Imat+Xmat; - %Ryy(Ryy>1)=1; - %errordlg(['The response data for ',EDP_Type,' will not yield a positive definitie correlation matrix. Consider revising the data or using the "Parameter" option instead to define the EDP data and the correlation matrix directly.'],'Problem Ahead!') - [~,Ly] = lu(Ryy); - Ly=Ly'; - end - - - counter=1; - for i=1:nRealizationx - RndVarVectorX=RndVarVector(i:i+size2-1,1); - Z=Dy*Ly*RndVarVectorX+My; - W(counter,:)=exp(Z)'; - counter=counter+1; - end - - if strcmp(EDP_Type,'SDR')==1 - REALIZATIONS.SDR=W; - if Response_Option==2; REALIZATIONS.SDR=[REALIZATIONS.SDR; X]; end - elseif strcmp(EDP_Type,'PFA')==1 - REALIZATIONS.PFA=W; - if Response_Option==2; REALIZATIONS.PFA=[REALIZATIONS.PFA; X]; end - elseif strcmp(EDP_Type,'PGA')==1 - REALIZATIONS.PGA=W; - if Response_Option==2; REALIZATIONS.PGA=[REALIZATIONS.PGA; X]; end - elseif strcmp(EDP_Type,'RDR')==1 - REALIZATIONS.RDR=W; - if Response_Option==2; REALIZATIONS.RDR=[REALIZATIONS.RDR; X]; end - elseif strcmp(EDP_Type,'VRD')==1 - REALIZATIONS.VRD=W; - if Response_Option==2; REALIZATIONS.VRD=[REALIZATIONS.VRD; X]; end - elseif strcmp(EDP_Type,'LINK ROT')==1 - REALIZATIONS.LINKROT=W; - if Response_Option==2; REALIZATIONS.LINKROT=[REALIZATIONS.LINKROT; X]; end - elseif strcmp(EDP_Type,'BEAM ROT')==1 - REALIZATIONS.BEAMROT=W; - if Response_Option==2; REALIZATIONS.BEAMROT=[REALIZATIONS.BEAMROT; X]; end - elseif strcmp(EDP_Type,'COL ROT')==1 - REALIZATIONS.COLROT=W; - if Response_Option==2; REALIZATIONS.COLROT=[REALIZATIONS.COLROT; X]; end - elseif strcmp(EDP_Type,'DWD')==1 - REALIZATIONS.DWD=W; - if Response_Option==2; REALIZATIONS.DWD=[REALIZATIONS.DWD; X]; end - elseif strcmp(EDP_Type,'RD')==1 - REALIZATIONS.RD=W; - if Response_Option==2; REALIZATIONS.RD=[REALIZATIONS.RD; X]; end - elseif strcmp(EDP_Type,'GENS1')==1 - REALIZATIONS.GENS1=W; - if Response_Option==2; REALIZATIONS.GENS1=[REALIZATIONS.GENS1; X]; end - elseif strcmp(EDP_Type,'GENS2')==1 - REALIZATIONS.GENS2=W; - if Response_Option==2; REALIZATIONS.GENS2=[REALIZATIONS.GENS2; X]; end - elseif strcmp(EDP_Type,'GENS3')==1 - REALIZATIONS.GENS3=W; - if Response_Option==2; REALIZATIONS.GENS3=[REALIZATIONS.GENS3; X]; end - elseif strcmp(EDP_Type,'GENF1')==1 - REALIZATIONS.GENF1=W; - if Response_Option==2; REALIZATIONS.GENF1=[REALIZATIONS.GENF1; X]; end - elseif strcmp(EDP_Type,'GENF2')==1 - REALIZATIONS.GENF2=W; - if Response_Option==2; REALIZATIONS.GENF2=[REALIZATIONS.GENF2; X]; end - elseif strcmp(EDP_Type,'GENF3')==1 - REALIZATIONS.GENF3=W; - if Response_Option==2; REALIZATIONS.GENF3=[REALIZATIONS.GENF3; X]; end - elseif strcmp(EDP_Type,'PFV')==1 - REALIZATIONS.PFV=W; - if Response_Option==2; REALIZATIONS.PFV=[REALIZATIONS.PFV; X]; end - elseif strcmp(EDP_Type,'GENF3')==1 - REALIZATIONS.ED=W; - if Response_Option==2; REALIZATIONS.ED=[REALIZATIONS.ED; X]; end - end -end \ No newline at end of file diff --git a/src/Get_REALIZATIONS_Matrix_SI.p b/src/Get_REALIZATIONS_Matrix_SI.p new file mode 100644 index 0000000..719e5cd Binary files /dev/null and b/src/Get_REALIZATIONS_Matrix_SI.p differ diff --git a/src/Get_Realization_EDP_MS.m b/src/Get_Realization_EDP_MS.m deleted file mode 100644 index 507ebfd..0000000 --- a/src/Get_Realization_EDP_MS.m +++ /dev/null @@ -1,52 +0,0 @@ - -function [Ri_EDP] = Get_Realization_EDP_MS(FRAGDATA,IDXF,N_Story,Ci_level,REALIZATIONS,n,Ri,im) - if strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'SDR')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.SDR_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PFA')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.PFA_S',num2str(im),'(Ri, n)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PGA')==1 - evalc(['Ri_EDP=REALIZATIONS.PFA_S',num2str(im),'(Ri, 1)']); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'LINK ROT')==1 - evalc(['Ri_EDP=REALIZATIONS.LINKROT_S',num2str(im),'(Ri, n)']); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'BEAM ROT')==1 - evalc(['Ri_EDP=REALIZATIONS.BEAMROT_S',num2str(im),'(Ri, n)']); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'COL ROT')==1 - evalc(['Ri_EDP=REALIZATIONS.COLROT_S',num2str(im),'(Ri, n)']); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'DWD')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.DWD_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'RD')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.RD_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS1')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENS1_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS2')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENS2_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS3')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENS3_S',num2str(im),'(Ri, n-1)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF1')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENF1_S',num2str(im),'(Ri, n)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF2')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENF2_S',num2str(im),'(Ri, n)']); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF3')==1 - Ri_EDP=0; - if Ci_level==1 && n1; evalc(['Ri_EDP=REALIZATIONS.GENF3_S',num2str(im),'(Ri, n)']); end - end -end \ No newline at end of file diff --git a/src/Get_Realization_EDP_MS.p b/src/Get_Realization_EDP_MS.p new file mode 100644 index 0000000..6ce5824 Binary files /dev/null and b/src/Get_Realization_EDP_MS.p differ diff --git a/src/Get_Realization_EDP_SI.m b/src/Get_Realization_EDP_SI.m deleted file mode 100644 index a77b80f..0000000 --- a/src/Get_Realization_EDP_SI.m +++ /dev/null @@ -1,51 +0,0 @@ -function [Ri_EDP] = Get_Realization_EDP_SI(FRAGDATA,IDXF,N_Story,Ci_level,REALIZATIONS,n,Ri,im) - if strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'SDR')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.SDR(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PFA')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.PFA(Ri, n); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'PGA')==1 - Ri_EDP=REALIZATIONS.PFA(Ri, 1); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'LINK ROT')==1 - Ri_EDP=REALIZATIONS.LINKROT(Ri, n); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'BEAM ROT')==1 - Ri_EDP=REALIZATIONS.BEAMROT(Ri, n); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'COL ROT')==1 - Ri_EDP=REALIZATIONS.COLROT(Ri, n); - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'DWD')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.DWD(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'RD')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.RD(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS1')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENS1(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS2')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENS2(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENS3')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENS3(Ri, n-1); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF1')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENF1(Ri, n); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF2')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENF2(Ri, n); end - elseif strcmp(FRAGDATA.DS_EDP(IDXF(1,1)),'GENF3')==1 - Ri_EDP=0; - if Ci_level==1 && n1; Ri_EDP=REALIZATIONS.GENF3(Ri, n); end - end -end diff --git a/src/Get_Realization_EDP_SI.p b/src/Get_Realization_EDP_SI.p new file mode 100644 index 0000000..4cc48ad Binary files /dev/null and b/src/Get_Realization_EDP_SI.p differ diff --git a/src/Get_Repair_Cost_Breakdown_by_Component.m b/src/Get_Repair_Cost_Breakdown_by_Component.m deleted file mode 100644 index cc522fe..0000000 --- a/src/Get_Repair_Cost_Breakdown_by_Component.m +++ /dev/null @@ -1,21 +0,0 @@ -function [Cost_Loss_Per_Component, Clabel]=Get_Repair_Cost_Breakdown_by_Component(Stripe,R_target,COMPDATA,DEAGG_DATA,CIDs) - -IDX_STRIP=find(DEAGG_DATA(:,1)==Stripe & DEAGG_DATA(:,6)==R_target); -DEAGG_STORY_LOSS=zeros(size(CIDs,1),1); -for i=1:size(CIDs,1) - for j=min(IDX_STRIP):max(IDX_STRIP) - if DEAGG_DATA(j,3)==CIDs(i,1) - DEAGG_STORY_LOSS(i,1) = DEAGG_STORY_LOSS(i,1) + DEAGG_DATA(j,4); - end - end - Name(i,1)=COMPDATA.C_shortername(CIDs(i,1)); -end -Clabel=unique(Name(:,1),'stable'); -Cost_Loss_Per_Component=zeros(size(Clabel,1),1); -for i=1:size(Clabel,1) - for j=1:size(DEAGG_STORY_LOSS,1) - if Clabel(i,1)==Name(j,1) - Cost_Loss_Per_Component(i,1) = Cost_Loss_Per_Component(i,1) + DEAGG_STORY_LOSS(j,1); - end - end -end \ No newline at end of file diff --git a/src/Get_Repair_Cost_Breakdown_by_Component.p b/src/Get_Repair_Cost_Breakdown_by_Component.p new file mode 100644 index 0000000..89128c9 Binary files /dev/null and b/src/Get_Repair_Cost_Breakdown_by_Component.p differ diff --git a/src/Get_Repair_Cost_Per_Ri.m b/src/Get_Repair_Cost_Per_Ri.m deleted file mode 100644 index c026a9e..0000000 --- a/src/Get_Repair_Cost_Per_Ri.m +++ /dev/null @@ -1,139 +0,0 @@ -function [CIDs, Elevation, CollapseCount, DemolitionCount, PlacardCount, InjuryCount, CasualtyCount, Realization_Filtered, REPAIR_COST_Per_Ri, REPAIR_COST_Per_Ri_Filtered, STORY_REPAIR_COST_SC_Per_Ri, STORY_REPAIR_COST_NSC_SDR_Per_Ri, STORY_REPAIR_COST_NSC_ACC_Per_Ri, MCAC, lambda, AreaMCAC]=Get_Repair_Cost_Per_Ri(Stripe) - -global MainDirectory ProjectName ProjectPath -cd (ProjectPath); load (ProjectName); cd (MainDirectory) - -if Component_Option==1 - CIDs = unique(C_Data(:,1),'sorted'); -else - CIDs=0; -end - -Elevation = 1:N_Story+1; - -% Count collpases and demolitions -CollapseCount=0; -DemolitionCount=0; -for Ri=1:nRealization - if COLLAPSE_LOSSES_Per_Ri(Ri,Stripe)~=0; CollapseCount = CollapseCount + 1; end - if DEMOLITION_LOSSES_Per_Ri(Ri,Stripe)~=0; DemolitionCount = DemolitionCount + 1; end -end - -% Count Placard -PlacardCount=0; -if Placardstatus==1 && Component_Option==1 - for i=1:size(DEAGG_DATA,1) - if DEAGG_DATA(i,1)==Stripe && DEAGG_DATA(i,16)==1; PlacardCount = PlacardCount + 1; end - end -end - -% Count Injuries and casualties -InjuryCount=0; -CasualtyCount=0; -if Casualtystatus==1 && Component_Option==1 - for i=1:size(DEAGG_DATA,1) - if DEAGG_DATA(i,1)==Stripe - InjuryCount = InjuryCount + DEAGG_DATA(i,13); - end - if DEAGG_DATA(i,1)==Stripe - CasualtyCount = CasualtyCount + DEAGG_DATA(i,14); - end - end -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -if Component_Option==1 - REPAIR_COST_Per_Ri=zeros(nRealization,1); - IDX_STRIP=find(DEAGG_DATA(:,1)==Stripe); - for Ri=1:nRealization - for i=min(IDX_STRIP):max(IDX_STRIP) - if DEAGG_DATA(i,6)==Ri - REPAIR_COST_Per_Ri(Ri,1)=REPAIR_COST_Per_Ri(Ri,1) + DEAGG_DATA(i,4); - end - end - end -else - REPAIR_COST_Per_Ri=zeros(nRealization,1); - IDX_STRIP=find(DEAGG_DATA(:,1)==Stripe); - for Ri=1:nRealization - for i=min(IDX_STRIP):max(IDX_STRIP) - if DEAGG_DATA(i,2)==Ri - REPAIR_COST_Per_Ri(Ri,1)=REPAIR_COST_Per_Ri(Ri,1) + DEAGG_DATA(i,7); - end - end - end -end - -counter=1; -sizex=nRealization-CollapseCount-DemolitionCount; -Realization_Filtered=zeros(sizex,1); -REPAIR_COST_Per_Ri_Filtered=zeros(sizex,1); -for Ri=1:size(REPAIR_COST_Per_Ri,1) - if COLLAPSE_LOSSES_Per_Ri(Ri,Stripe)==0 && DEMOLITION_LOSSES_Per_Ri(Ri,Stripe)==0 - Realization_Filtered(counter,1)=Ri; - REPAIR_COST_Per_Ri_Filtered(counter,1)=REPAIR_COST_Per_Ri(Ri,1); - counter=counter+1; - end -end - -if Component_Option==1 - STORY_REPAIR_COST_SC_Per_Ri=zeros(nRealization,N_Story+1); - STORY_REPAIR_COST_NSC_SDR_Per_Ri=zeros(nRealization,N_Story+1); - STORY_REPAIR_COST_NSC_ACC_Per_Ri=zeros(nRealization,N_Story+1); - for Ri=1:nRealization - for n=N_Story+1:-1:1 - for i=min(IDX_STRIP):max(IDX_STRIP) - if DEAGG_DATA(i,6)==Ri && DEAGG_DATA(i,2)==n && DEAGG_DATA(i,5)==1 - STORY_REPAIR_COST_SC_Per_Ri(Ri,n) = STORY_REPAIR_COST_SC_Per_Ri(Ri,n) + DEAGG_DATA(i,4); - elseif DEAGG_DATA(i,6)==Ri && DEAGG_DATA(i,2)==n && DEAGG_DATA(i,5)==2 - STORY_REPAIR_COST_NSC_SDR_Per_Ri(Ri,n) = STORY_REPAIR_COST_NSC_SDR_Per_Ri(Ri,n) + DEAGG_DATA(i,4); - elseif DEAGG_DATA(i,6)==Ri && DEAGG_DATA(i,2)==n && DEAGG_DATA(i,5)==3 - STORY_REPAIR_COST_NSC_ACC_Per_Ri(Ri,n) = STORY_REPAIR_COST_NSC_ACC_Per_Ri(Ri,n) + DEAGG_DATA(i,4); - end - end - end - end -else - STORY_REPAIR_COST_SC_Per_Ri=zeros(nRealization,N_Story+1); - STORY_REPAIR_COST_NSC_SDR_Per_Ri=zeros(nRealization,N_Story+1); - STORY_REPAIR_COST_NSC_ACC_Per_Ri=zeros(nRealization,N_Story+1); - for Ri=1:nRealization - for n=N_Story+1:-1:1 - for i=min(IDX_STRIP):max(IDX_STRIP) - if DEAGG_DATA(i,2)==Ri && DEAGG_DATA(i,3)==n - STORY_REPAIR_COST_SC_Per_Ri (Ri,n) = STORY_REPAIR_COST_SC_Per_Ri (Ri,n) + DEAGG_DATA(i,4); - STORY_REPAIR_COST_NSC_SDR_Per_Ri(Ri,n) = STORY_REPAIR_COST_NSC_SDR_Per_Ri(Ri,n) + DEAGG_DATA(i,5); - STORY_REPAIR_COST_NSC_ACC_Per_Ri(Ri,n) = STORY_REPAIR_COST_NSC_ACC_Per_Ri(Ri,n) + DEAGG_DATA(i,6); - end - end - end - end -end - - -MCAC=0; -lambda=0; -AreaMCAC=0; -if HazardDataStatus ==1 - %% Annual Rate of Exceeding the repair cost - MCAC=0.0:(max(0.01,max(REPAIR_COST_Per_Ri)*1.1)-min(REPAIR_COST_Per_Ri))/50:max(0.01,max(REPAIR_COST_Per_Ri)*1.1); - lambda=normcdf(MCAC,mean(REPAIR_COST_Per_Ri_Filtered),std(REPAIR_COST_Per_Ri_Filtered)); - lambda=1-lambda; - HazardSlope = abs(diff(MAF)); - for i=1:length(IMpoints)-1 - if TargetIM(1,Stripe)>=IMpoints(1,i) && TargetIM(1,Stripe) P_DS_EDP_2 - % If the current DS is part of a mutually exclusive DS scenario, then a unifromly - % distributed random variable to find which one you will be in - if strcmp(FRAGDATA.DS_Hierarchy (IDXF(DSi,1)),'Mutually Exclusive')==1 && DSi~=Ci_nDS - RndVar_P_DSseq=randi(100)/100; - if RndVar_P_DSseq >= FRAGDATA.DS_P (IDXF(DSi,1)) - DSi=DSi+1; - end - end - - ActiveDS=DSi; - break; - end - - end - end - - if ActiveDS~=0 - if strcmp(FRAGDATA.DS_UnsafePlacardFlag(IDXF(ActiveDS,1)),'YES')==1; CountPlacardFlag=CountPlacardFlag+1; end - end - end - DEAGG_DATA(i,15)=CountPlacardFlag; - if CountPlacardFlag/nUnits>=FRAGDATA.DS_UnsafePlacardmedian(IDXF(1,1)) - DEAGG_DATA(i,16)=1; - else - DEAGG_DATA(i,16)=0; - end - - if rem(i,size(DEAGG_DATA,1)/10)==0 - app.ProgressText.Value=['ESTIMATING UNSAFE PLACARD PROBABILITY ',num2str(round(i*100/size(DEAGG_DATA,1))),'%']; - app.ProgressBar.Position=[9 5 i/size(DEAGG_DATA,1)*613 6]; - drawnow - end -end \ No newline at end of file diff --git a/src/Get_Unsafe_Placard.p b/src/Get_Unsafe_Placard.p new file mode 100644 index 0000000..6686562 Binary files /dev/null and b/src/Get_Unsafe_Placard.p differ diff --git a/src/Import_ShearModel_Data_from_Excel.m b/src/Import_ShearModel_Data_from_Excel.m deleted file mode 100644 index 6ad433c..0000000 --- a/src/Import_ShearModel_Data_from_Excel.m +++ /dev/null @@ -1,14 +0,0 @@ -function [HStory, Load, Mass, Parameters] = Import_ShearModel_Data_from_Excel(ModelType, ExcelFilePath, ExcelFileName, N_Story) - -cd(ExcelFilePath) - -if ModelType==1; SheetName='Elastic'; nParameters=1; end -if ModelType==2; SheetName='Bilinear'; nParameters=3; end -if ModelType==3; SheetName='IMK Bilinear'; nParameters=9; end -if ModelType==4; SheetName='IMK PeakOriented'; nParameters=9; end -[num,txt,Data] = xlsread(ExcelFileName,'Story_Height','B2:B100'); HStory = num(1:N_Story,1); -[num,txt,Data] = xlsread(ExcelFileName,'Load','B2:B100'); Load = num(1:N_Story,1); -[num,txt,Data] = xlsread(ExcelFileName,'Mass','B2:B100'); Mass = num(1:N_Story,1); -[num,txt,Data] = xlsread(ExcelFileName,SheetName,'B2:Z100'); Parameters = num(1:N_Story,1:nParameters); - -end diff --git a/src/Import_ShearModel_Data_from_Excel.p b/src/Import_ShearModel_Data_from_Excel.p new file mode 100644 index 0000000..93496b3 Binary files /dev/null and b/src/Import_ShearModel_Data_from_Excel.p differ diff --git a/src/Initialize_Project.m b/src/Initialize_Project.m index e571d3d..759890c 100644 --- a/src/Initialize_Project.m +++ b/src/Initialize_Project.m @@ -23,9 +23,7 @@ function Initialize_Project(MainDirectory, ProjectPath, ProjectName, Units) end end -cd (ProjectPath) -save(ProjectName, 'COMPDATA', 'FRAGDATA','Units') -cd (MainDirectory) +save(strcat(ProjectPath,ProjectName), 'COMPDATA', 'FRAGDATA','Units') % Create porject directory and save inside it the intialized project data using % ProjectData.mat file @@ -104,9 +102,7 @@ function Initialize_Project(MainDirectory, ProjectPath, ProjectName, Units) RANGE.PFV = [0.0:0.01:6.0]; end -cd (ProjectPath) -save(ProjectName, 'BuildingDataStatus', 'ComponentDataStatus','HazardDataStatus','ResponseDataStatus','LossDataStatus', 'DemolitionStatus','CollapseStatus','Placardstatus','Casualtystatus','PopModelstatus','Component_Data','IMstatus','IMstart','IMincr','IMend','IMpoints','nIMpoints','TargetIMstart','TargetIMend','TargetIM','TargetIM_Option','ResultsStatus','nStripe','N_GM','Option5_Type','Option5Data','Option6Data','Timestatus','EvalTimeOption','TimeModel','-append') -save(ProjectName, 'Demolition_Option', 'DemolishMedianRDR','DemolishSigmaRDR','DemolishMedianVRD','DemolishSigmaVRD','DemolishCorr','CollapseSDR','CPS_Option','MedianCPS','SigmaCPS','ResponseSA','RANGE','-append') -cd (MainDirectory) +save(strcat(ProjectPath,ProjectName), 'BuildingDataStatus', 'ComponentDataStatus','HazardDataStatus','ResponseDataStatus','LossDataStatus', 'DemolitionStatus','CollapseStatus','Placardstatus','Casualtystatus','PopModelstatus','Component_Data','IMstatus','IMstart','IMincr','IMend','IMpoints','nIMpoints','TargetIMstart','TargetIMend','TargetIM','TargetIM_Option','ResultsStatus','nStripe','N_GM','Option5_Type','Option5Data','Option6Data','Timestatus','EvalTimeOption','TimeModel','-append') +save(strcat(ProjectPath,ProjectName), 'Demolition_Option', 'DemolishMedianRDR','DemolishSigmaRDR','DemolishMedianVRD','DemolishSigmaVRD','DemolishCorr','CollapseSDR','CPS_Option','MedianCPS','SigmaCPS','ResponseSA','RANGE','-append') end \ No newline at end of file diff --git a/src/LossCode_FEMAP58_CO1.p b/src/LossCode_FEMAP58_CO1.p index 75c4f3f..9009b11 100644 Binary files a/src/LossCode_FEMAP58_CO1.p and b/src/LossCode_FEMAP58_CO1.p differ diff --git a/src/LossCode_FEMAP58_CO2.p b/src/LossCode_FEMAP58_CO2.p index fa66173..1c079ff 100644 Binary files a/src/LossCode_FEMAP58_CO2.p and b/src/LossCode_FEMAP58_CO2.p differ diff --git a/src/LossCode_FEMAP58_CO3.p b/src/LossCode_FEMAP58_CO3.p index 29810ae..f98ac18 100644 Binary files a/src/LossCode_FEMAP58_CO3.p and b/src/LossCode_FEMAP58_CO3.p differ diff --git a/src/LossCode_PEER_CO1.p b/src/LossCode_PEER_CO1.p index 2a94013..b9cce52 100644 Binary files a/src/LossCode_PEER_CO1.p and b/src/LossCode_PEER_CO1.p differ diff --git a/src/LossCode_PEER_CO1_IDA.p b/src/LossCode_PEER_CO1_IDA.p index 82dd2a6..998473b 100644 Binary files a/src/LossCode_PEER_CO1_IDA.p and b/src/LossCode_PEER_CO1_IDA.p differ diff --git a/src/LossCode_PEER_CO2.p b/src/LossCode_PEER_CO2.p index b117f81..493e797 100644 Binary files a/src/LossCode_PEER_CO2.p and b/src/LossCode_PEER_CO2.p differ diff --git a/src/LossCode_PEER_CO2_IDA.p b/src/LossCode_PEER_CO2_IDA.p index 3b03214..0f1e99e 100644 Binary files a/src/LossCode_PEER_CO2_IDA.p and b/src/LossCode_PEER_CO2_IDA.p differ diff --git a/src/LossCode_PEER_CO3.p b/src/LossCode_PEER_CO3.p index a3a3668..aa89ff0 100644 Binary files a/src/LossCode_PEER_CO3.p and b/src/LossCode_PEER_CO3.p differ diff --git a/src/LossCode_PEER_CO3_IDA.p b/src/LossCode_PEER_CO3_IDA.p index e8ec53a..0bdb358 100644 Binary files a/src/LossCode_PEER_CO3_IDA.p and b/src/LossCode_PEER_CO3_IDA.p differ diff --git a/src/MDoF_CREATOR_EIGEN.p b/src/MDoF_CREATOR_EIGEN.p index 8127b39..3e0a369 100644 Binary files a/src/MDoF_CREATOR_EIGEN.p and b/src/MDoF_CREATOR_EIGEN.p differ diff --git a/src/MDoF_CREATOR_ELASTIC.p b/src/MDoF_CREATOR_ELASTIC.p index 0193fae..c7e0baf 100644 Binary files a/src/MDoF_CREATOR_ELASTIC.p and b/src/MDoF_CREATOR_ELASTIC.p differ diff --git a/src/MDoF_CREATOR_MAIN.p b/src/MDoF_CREATOR_MAIN.p index d912655..f13b8ce 100644 Binary files a/src/MDoF_CREATOR_MAIN.p and b/src/MDoF_CREATOR_MAIN.p differ diff --git a/src/MDoF_Get_IM.m b/src/MDoF_Get_IM.m deleted file mode 100644 index 8e07328..0000000 --- a/src/MDoF_Get_IM.m +++ /dev/null @@ -1,16 +0,0 @@ -function [GM]=MDoF_Get_IM(GMFolderName, T1, GM, g, zeta, SA_metric) - -if SA_metric==1 - GM.GMpsaT1 = cent_diff(GMFolderName, T1, GM.GMdt, zeta, [GM.GMname '.th'], g)/g; -else - Sa_PRODUCT=1; - nsample=0; - for Ti=0.2*T1:0.01:3*T1 - nsample=nsample+1; - end - for Ti=0.2*T1:0.01:3*T1 - Sa_Ti = cent_diff(GMFolderName, Ti, GM.GMdt, zeta, [GM.GMname '.th'], g)/g; - Sa_PRODUCT=Sa_PRODUCT*Sa_Ti^(1/nsample); - end - GM.GMpsaT1=(Sa_PRODUCT); -end \ No newline at end of file diff --git a/src/MDoF_Get_IM.p b/src/MDoF_Get_IM.p new file mode 100644 index 0000000..09d062e Binary files /dev/null and b/src/MDoF_Get_IM.p differ diff --git a/src/MDoF_Read_Data.m b/src/MDoF_Read_Data.m deleted file mode 100644 index e007a79..0000000 --- a/src/MDoF_Read_Data.m +++ /dev/null @@ -1,55 +0,0 @@ - -function [DATA]= MDoF_Read_Data(MainDirectory,RFname,GM,GMFolderName,Nstory,g,SFcurrent,DATA) - -cd (RFname); % Go Inside the 'Results' Folder -cd (GM.GMname); % Go Inside the Current GM Folder - -% Read Time -DATA.TimeX= importdata('Time.out'); - -% Read Story Drifts -for i=1:Nstory - FilenameX1=strcat('SDR',num2str(i),'.out'); - evalc(strcat('DATA.SDR',num2str(i),' = importdata(''',FilenameX1,''')')); -end - - -% Read Floor Accelerations -for i=1:Nstory+1 - FilenameX2=strcat('RFA',num2str(i),'.out'); - evalc(strcat('DATA.RFA',num2str(i),' = importdata(''',FilenameX2,''')')); -end - - -%% Calculate Absolute Acceleration per Floor -cd (MainDirectory); -cd (GMFolderName); -A = importdata([GM.GMname '.th']); -L = length(A(:,1)); -CL = length(A(1,:)); -for i = 1:L - GMArrangement((1+(i-1)*CL):(CL+(i-1)*CL),1) = A(i,:)'; -end -evalc(strcat('Time=DATA.TimeX(:,1)')); -Time2 = 0:GM.GMdt:(length(GMArrangement)-1)*GM.GMdt; -Eq (:,1) = Time2; -Eq (:,2) = GMArrangement; -DATA.EQ_Inter = interp1(Eq(:,1),Eq(:,2), Time(11:end,1)); - -for i=1:Nstory+1 - evalc(strcat('DATA.PFA',num2str(i),'= DATA.RFA', num2str(i), '(11:end,1)/g + SFcurrent * DATA.EQ_Inter(:,1)')); -end - -%% -for i=1:Nstory - evalc(strcat('DATA.SDRincrmaxi(i)=max(abs(DATA.SDR',num2str(i),'))')); - evalc(strcat('DATA.RDRincrmaxi(i)=abs(DATA.SDR',num2str(i),'(end,1))')); -end -for i=1:Nstory+1 - evalc(strcat('DATA.PFAincrmaxi(i)=max(abs(DATA.PFA',num2str(i),'))')); -end -DATA.SDRincrmax=max(DATA.SDRincrmaxi); -DATA.PFAincrmax=max(DATA.PFAincrmaxi); -DATA.RDRincrmax=max(DATA.RDRincrmaxi); - -cd (MainDirectory); diff --git a/src/MDoF_Read_Data.p b/src/MDoF_Read_Data.p new file mode 100644 index 0000000..9222373 Binary files /dev/null and b/src/MDoF_Read_Data.p differ diff --git a/src/MDoF_Run_OpenSEES.p b/src/MDoF_Run_OpenSEES.p index 79cd03c..6d4e629 100644 Binary files a/src/MDoF_Run_OpenSEES.p and b/src/MDoF_Run_OpenSEES.p differ diff --git a/src/MDoF_Save_IDA_Data.m b/src/MDoF_Save_IDA_Data.m deleted file mode 100644 index 25157b8..0000000 --- a/src/MDoF_Save_IDA_Data.m +++ /dev/null @@ -1,64 +0,0 @@ - -function MDoF_Save_IDA_Data(MainDirectory,RFname,GM,Nstory,IncrNo,IncrDATA,Delete_Flag) - -%% Delete All OpenSEES Output Files -if Delete_Flag==1 - cd (RFname); - cd (GM.GMname); - delete *.out - cd (MainDirectory); -end - -%% Save Predetermined Limit Values at End of Vectors for IDA Ploting Reasons -IncrDATA.SA (IncrNo) = max(IncrDATA.SA); - -IncrDATA.SDR_Max (IncrNo) = 0.2; -IncrDATA.RDR_Max (IncrNo) = 0.2; -% IncrDATA.SF1_LC_Max (IncrNo) = max(IncrDATA.SF1_LC_Max); -for i=1:Nstory - evalc(strcat('IncrDATA.SDR',num2str(i),'(IncrNo)=0.2')); - evalc(strcat('IncrDATA.RDR',num2str(i),'(IncrNo)=0.2')); -end - -for i=1:Nstory+1 - evalc(strcat('IncrDATA.PFA',num2str(i),'(IncrNo)= max (IncrDATA.PFA',num2str(i),')')); -end - -%% Save Processed IDA Data to a Text File in a Different Folder for Each GM -cd (RFname); -cd (GM.GMname); - -% SDR IDA DATA -file5 = fopen('IDA SDR.txt','wt'); -for incr=1:IncrNo - fprintf(file5,'%f\t',IncrDATA.SA(incr)); - for i = 1:Nstory - fprintf(file5,'%f\t',eval(['IncrDATA.SDR' num2str(i) '(' num2str(incr) ')'])); - end - fprintf(file5,'\n'); -end -fclose(file5); - -% RDR IDA DATA -file7 = fopen('IDA RDR.txt','wt'); -for incr=1:IncrNo - fprintf(file7,'%f\t%f\t',IncrDATA.SA(incr), IncrDATA.RDR_Max(incr)); -% for i = 1:Nstory -% fprintf(file7,'%f\t',eval(['IncrDATA.RDR' num2str(i) '(' num2str(incr) ')'])); -% end - fprintf(file7,'\n'); -end -fclose(file7); - -% PFA IDA DATA -file6 = fopen('IDA PFA.txt','wt'); -for incr=1:IncrNo - fprintf(file6,'%f\t',IncrDATA.SA(incr)); - for i = 1:Nstory+1 - fprintf(file6,'%f\t',eval(['IncrDATA.PFA' num2str(i) '(' num2str(incr) ')'])); - end - fprintf(file6,'\n'); -end -fclose(file6); - -cd (MainDirectory); \ No newline at end of file diff --git a/src/MDoF_Save_IDA_Data.p b/src/MDoF_Save_IDA_Data.p new file mode 100644 index 0000000..191550e Binary files /dev/null and b/src/MDoF_Save_IDA_Data.p differ diff --git a/src/MDoF_Save_Incr_Data.m b/src/MDoF_Save_Incr_Data.m deleted file mode 100644 index b89e948..0000000 --- a/src/MDoF_Save_Incr_Data.m +++ /dev/null @@ -1,38 +0,0 @@ -function [IncrDATA]= MDoF_Save_Incr_Data(MainDirectory,RFname,GM,Nstory,IncrNo, SAcurrent,DATA,g,SFcurrent,IncrDATA) - -% Save SA level in Storage Vector "SA" -IncrDATA.SA (IncrNo) = SAcurrent; - -% Save Maximum SDR for Story i in Storage Vector "SDRi" -for i=1:Nstory - evalc(strcat('IncrDATA.SDR',num2str(i),'(IncrNo) = max(abs (DATA.SDR', num2str(i), '(:,1)))')); -end - -% Save Residual (Last value) SDR for Story i in Storage Vector "RDRi" -for i=1:Nstory - evalc(strcat('IncrDATA.RDR',num2str(i),'(IncrNo) = abs (DATA.SDR', num2str(i), '(end,1))')); -end - -% Save Maximum Absolute Acceleration for Floor i in Storage Vector "PFAi" -for i=1:Nstory+1 - evalc(strcat('IncrDATA.PFA',num2str(i),'(IncrNo) = max(abs (DATA.PFA' , num2str(i), '))')); -end - - -% Save Maximum SDR for All Stories in Storage Vector "SDR_Max" -IncrDATA.SDR_Max (IncrNo)=0.0; -for i=1:Nstory - x = eval(['IncrDATA.SDR' num2str(i) '(IncrNo)']); - if x >= IncrDATA.SDR_Max (IncrNo) - IncrDATA.SDR_Max (IncrNo) = x; - end -end - -% Save Maximum RDR for All Stories in Storage Vector "RDR_Max" -IncrDATA.RDR_Max (IncrNo)=0.0; -for i=1:Nstory - x = eval(['IncrDATA.RDR' num2str(i) '(IncrNo)']); - if x >= IncrDATA.RDR_Max (IncrNo) - IncrDATA.RDR_Max (IncrNo) = x; - end -end diff --git a/src/MDoF_Save_Incr_Data.p b/src/MDoF_Save_Incr_Data.p new file mode 100644 index 0000000..b65ae72 Binary files /dev/null and b/src/MDoF_Save_Incr_Data.p differ diff --git a/src/Module_Building_App.mlapp b/src/Module_Building_App.mlapp index 783c6f9..e3f0b36 100644 Binary files a/src/Module_Building_App.mlapp and b/src/Module_Building_App.mlapp differ diff --git a/src/Module_Collapse_App.mlapp b/src/Module_Collapse_App.mlapp index 70ce9e6..391f3be 100644 Binary files a/src/Module_Collapse_App.mlapp and b/src/Module_Collapse_App.mlapp differ diff --git a/src/Module_Component_App.mlapp b/src/Module_Component_App.mlapp index 39cccac..24ed1f1 100644 Binary files a/src/Module_Component_App.mlapp and b/src/Module_Component_App.mlapp differ diff --git a/src/Module_Component_Option1_App.mlapp b/src/Module_Component_Option1_App.mlapp index f10c800..f9936eb 100644 Binary files a/src/Module_Component_Option1_App.mlapp and b/src/Module_Component_Option1_App.mlapp differ diff --git a/src/Module_Component_Option2_App.mlapp b/src/Module_Component_Option2_App.mlapp index 6da2448..58517f9 100644 Binary files a/src/Module_Component_Option2_App.mlapp and b/src/Module_Component_Option2_App.mlapp differ diff --git a/src/Module_Component_Option3_App.mlapp b/src/Module_Component_Option3_App.mlapp index 052e423..fc4dc45 100644 Binary files a/src/Module_Component_Option3_App.mlapp and b/src/Module_Component_Option3_App.mlapp differ diff --git a/src/Module_Demolition_App.mlapp b/src/Module_Demolition_App.mlapp index 20de7fd..adffbfe 100644 Binary files a/src/Module_Demolition_App.mlapp and b/src/Module_Demolition_App.mlapp differ diff --git a/src/Module_Fragility_App.mlapp b/src/Module_Fragility_App.mlapp index 0c98f15..69d816e 100644 Binary files a/src/Module_Fragility_App.mlapp and b/src/Module_Fragility_App.mlapp differ diff --git a/src/Module_Fragility_Edit_App.mlapp b/src/Module_Fragility_Edit_App.mlapp index 6f09592..5f346ff 100644 Binary files a/src/Module_Fragility_Edit_App.mlapp and b/src/Module_Fragility_Edit_App.mlapp differ diff --git a/src/Module_Fragility_Explorer_App.mlapp b/src/Module_Fragility_Explorer_App.mlapp index ac44bee..f638a50 100644 Binary files a/src/Module_Fragility_Explorer_App.mlapp and b/src/Module_Fragility_Explorer_App.mlapp differ diff --git a/src/Module_Fragility_Multivariate_App.mlapp b/src/Module_Fragility_Multivariate_App.mlapp index 27f0540..34493b6 100644 Binary files a/src/Module_Fragility_Multivariate_App.mlapp and b/src/Module_Fragility_Multivariate_App.mlapp differ diff --git a/src/Module_Fragility_Univariate_App.mlapp b/src/Module_Fragility_Univariate_App.mlapp index ad4f68f..e896eb5 100644 Binary files a/src/Module_Fragility_Univariate_App.mlapp and b/src/Module_Fragility_Univariate_App.mlapp differ diff --git a/src/Module_Hazard_App.mlapp b/src/Module_Hazard_App.mlapp index 56b7693..44e817a 100644 Binary files a/src/Module_Hazard_App.mlapp and b/src/Module_Hazard_App.mlapp differ diff --git a/src/Module_IM_App.mlapp b/src/Module_IM_App.mlapp index 1e35f19..d77f8bc 100644 Binary files a/src/Module_IM_App.mlapp and b/src/Module_IM_App.mlapp differ diff --git a/src/Module_Option6_RMF_App.mlapp b/src/Module_Option6_RMF_App.mlapp index 76066e5..b73e2fc 100644 Binary files a/src/Module_Option6_RMF_App.mlapp and b/src/Module_Option6_RMF_App.mlapp differ diff --git a/src/Module_Population_App.mlapp b/src/Module_Population_App.mlapp index 2e18f6b..03d9366 100644 Binary files a/src/Module_Population_App.mlapp and b/src/Module_Population_App.mlapp differ diff --git a/src/Module_PredictorData_App.mlapp b/src/Module_PredictorData_App.mlapp index 8a6bb98..858d0e0 100644 Binary files a/src/Module_PredictorData_App.mlapp and b/src/Module_PredictorData_App.mlapp differ diff --git a/src/Module_Report_App.mlapp b/src/Module_Report_App.mlapp index 5016f4b..d957344 100644 Binary files a/src/Module_Report_App.mlapp and b/src/Module_Report_App.mlapp differ diff --git a/src/Module_Response_App.mlapp b/src/Module_Response_App.mlapp index aabc833..7db1db1 100644 Binary files a/src/Module_Response_App.mlapp and b/src/Module_Response_App.mlapp differ diff --git a/src/Module_Response_Option1_App.mlapp b/src/Module_Response_Option1_App.mlapp index 8f0bebf..6adfdd4 100644 Binary files a/src/Module_Response_Option1_App.mlapp and b/src/Module_Response_Option1_App.mlapp differ diff --git a/src/Module_Response_Option2or3_App.mlapp b/src/Module_Response_Option2or3_App.mlapp index e3bb3fb..756d196 100644 Binary files a/src/Module_Response_Option2or3_App.mlapp and b/src/Module_Response_Option2or3_App.mlapp differ diff --git a/src/Module_Response_Option4_App.mlapp b/src/Module_Response_Option4_App.mlapp index fb72932..71a99c2 100644 Binary files a/src/Module_Response_Option4_App.mlapp and b/src/Module_Response_Option4_App.mlapp differ diff --git a/src/Module_Response_Option5_App.mlapp b/src/Module_Response_Option5_App.mlapp index 3dd884f..6280353 100644 Binary files a/src/Module_Response_Option5_App.mlapp and b/src/Module_Response_Option5_App.mlapp differ diff --git a/src/Module_Response_Option6_App.mlapp b/src/Module_Response_Option6_App.mlapp index 4f2601e..14c6cae 100644 Binary files a/src/Module_Response_Option6_App.mlapp and b/src/Module_Response_Option6_App.mlapp differ diff --git a/src/Module_Run_Options_App.mlapp b/src/Module_Run_Options_App.mlapp index d80373e..932d011 100644 Binary files a/src/Module_Run_Options_App.mlapp and b/src/Module_Run_Options_App.mlapp differ diff --git a/src/Module_SummaryPlot_App.mlapp b/src/Module_SummaryPlot_App.mlapp index 95d453e..cf6200c 100644 Binary files a/src/Module_SummaryPlot_App.mlapp and b/src/Module_SummaryPlot_App.mlapp differ diff --git a/src/Module_SummaryPlot_FEMAP58_App.mlapp b/src/Module_SummaryPlot_FEMAP58_App.mlapp index 29fd5b3..a78b277 100644 Binary files a/src/Module_SummaryPlot_FEMAP58_App.mlapp and b/src/Module_SummaryPlot_FEMAP58_App.mlapp differ diff --git a/src/Module_SummaryPlot_PEER_App.mlapp b/src/Module_SummaryPlot_PEER_App.mlapp index f93740e..af52d21 100644 Binary files a/src/Module_SummaryPlot_PEER_App.mlapp and b/src/Module_SummaryPlot_PEER_App.mlapp differ diff --git a/src/Module_Time_App.mlapp b/src/Module_Time_App.mlapp index cfdc7e3..8b4bbbb 100644 Binary files a/src/Module_Time_App.mlapp and b/src/Module_Time_App.mlapp differ diff --git a/src/Module_Visualize_App.mlapp b/src/Module_Visualize_App.mlapp index c88fdc1..ce7fa93 100644 Binary files a/src/Module_Visualize_App.mlapp and b/src/Module_Visualize_App.mlapp differ diff --git a/src/Plot_EAL.p b/src/Plot_EAL.p new file mode 100644 index 0000000..da58719 Binary files /dev/null and b/src/Plot_EAL.p differ diff --git a/src/Plot_EDP_Data_Option5.m b/src/Plot_EDP_Data_Option5.m index ff4c42e..52024d2 100644 --- a/src/Plot_EDP_Data_Option5.m +++ b/src/Plot_EDP_Data_Option5.m @@ -1,13 +1,9 @@ function Plot_EDP_Data_Option5(ProjectPath, ProjectName, MainDirectory) -cd(ProjectPath) -load (ProjectName,'Option5_Type','N_GM','N_Story'); -cd(MainDirectory) +load (strcat(ProjectPath,ProjectName),'Option5_Type','N_GM','N_Story'); if Option5_Type==2 || Option5_Type==3 - cd(ProjectPath) - load (ProjectName,'EDP_Data'); - cd(MainDirectory) + load (strcat(ProjectPath,ProjectName),'EDP_Data'); figure('position',[500 300 900 300],'color','white'); subplot(1,3,1) @@ -70,9 +66,7 @@ function Plot_EDP_Data_Option5(ProjectPath, ProjectName, MainDirectory) set(gca,'YTick',Elevation) set(h,'fontsize',10); else - cd(ProjectPath) - load (ProjectName,'ResponseDataFolderPath','IDAFilename'); - cd(MainDirectory) + load (strcat(ProjectPath,ProjectName),'ResponseDataFolderPath','IDAFilename'); Plot_IDA_Data_Option5 (N_GM,MainDirectory,ResponseDataFolderPath,IDAFilename.SDR,IDAFilename.PFA,IDAFilename.RDR); end diff --git a/src/Plot_Population_Model.m b/src/Plot_Population_Model.m deleted file mode 100644 index 267b17b..0000000 --- a/src/Plot_Population_Model.m +++ /dev/null @@ -1,38 +0,0 @@ -function Plot_Population_Model(OccupancyName,PopModel,Units) - -if Units==1; unitlabel='sq. feet'; else unitlabel='sq. meter'; end - -figure('position',[500 300 850 300],'color','white'); - -subplot(1,2,1) -sgtitle (['Occupancy: ',OccupancyName,' -> Peak population: ',num2str(PopModel.PeakPopP),' people per ', num2str(PopModel.PeakPopArea),' ', unitlabel]) -hold on; grid on; box on; -plot(PopModel.PopVarPerHourDay(:,1)*100,'-k','linewidth',2) -plot(PopModel.PopVarPerHourDay(:,2)*100,'-r','linewidth',2) -set(gca,'XLim',[1 24]) -set(gca,'YLim',[0 110]) -legend1=legend('Weekday','Weekend'); -set(legend1,'location','southwest'); -ylabel ('Variation'); -xticks(1:24); -yticks(0:20:100); -xticklabels({'Midnight','','','','','','06:00 am','','','','','','Noon','','','','','','06:00 pm','','','','','11:00 pm'}); -rotateXLabels( gca(), 90) -set(gca, 'fontname', 'times', 'fontsize',14); - -subplot(1,2,2) -hold on; grid on; box on; -plot(PopModel.PopVarPerMonth(:,1)*100,'-k','linewidth',2) -plot(PopModel.PopVarPerMonth(:,2)*100,'-r','linewidth',2) -set(gca,'XLim',[1 12]) -set(gca,'YLim',[0 110]) -legend1=legend('Weekday','Weekend'); -set(legend1,'location','southwest'); -ylabel ('Variation'); -xticks(1:12); -yticks(0:20:100); -xticklabels({'Jan','Feb','Mar','Apr','May','June','July','Aug','Sep','Oct','Nov','Dec'}); -rotateXLabels( gca(), 90) -set(gca, 'fontname', 'times', 'fontsize',16); - -end \ No newline at end of file diff --git a/src/Plot_Population_Model.p b/src/Plot_Population_Model.p new file mode 100644 index 0000000..d84c984 Binary files /dev/null and b/src/Plot_Population_Model.p differ diff --git a/src/Plot_RepairCostBreakdown_by_Component.m b/src/Plot_RepairCostBreakdown_by_Component.m index 74f5462..121acbc 100644 --- a/src/Plot_RepairCostBreakdown_by_Component.m +++ b/src/Plot_RepairCostBreakdown_by_Component.m @@ -64,7 +64,8 @@ DEAGG_STORY_LOSS(i,1) = DEAGG_STORY_LOSS(i,1) + DEAGG_DATA(j,4); end end - Name(i,1)=COMPDATA.C_shortername(CIDs(i,1)); + Name(i,1) = COMPDATA.C_shortername(CIDs(i,1)); + ID(i,1) = COMPDATA.C_ID(CIDs(i,1)); end Clabel=unique(Name(:,1),'stable'); diff --git a/src/Plot_RepairTimeBreakdown_by_Component.m b/src/Plot_RepairTimeBreakdown_by_Component.m index 7220786..a97b32f 100644 --- a/src/Plot_RepairTimeBreakdown_by_Component.m +++ b/src/Plot_RepairTimeBreakdown_by_Component.m @@ -24,14 +24,14 @@ for n=1:N_Story+1 MaxTimeStory(1,n)=0; - for i=1:size(TimeModel.TimeMatrix,1) - if TimeModel.TimeMatrix(i,1)==0; break; end - for j=1:size(TimeModel.TimeMatrix(i,:),2) - if TimeModel.TimeMatrix(i,j)==0; break; end - IDX=find(CIDs==TimeModel.TimeMatrix(i,j)) ; - MaxTimeStory(1,n)=MaxTimeStory(1,n)+max(DEAGG_STORY_LOSS(IDX,n)); + for i=1:size(TimeModel.TimeMatrix,1) + if TimeModel.TimeMatrix(i,1)==0; break; end + for j=1:size(TimeModel.TimeMatrix(i,:),2) + if TimeModel.TimeMatrix(i,j)==0; break; end + IDX=find(CIDs==TimeModel.TimeMatrix(i,j)) ; + MaxTimeStory(1,n)=MaxTimeStory(1,n)+max(DEAGG_STORY_LOSS(IDX,n)); + end end - end end diff --git a/src/Plot_RepairTime_vs_Realization.p b/src/Plot_RepairTime_vs_Realization.p new file mode 100644 index 0000000..ca46a51 Binary files /dev/null and b/src/Plot_RepairTime_vs_Realization.p differ diff --git a/src/Process_Imported_Component_Data.m b/src/Process_Imported_Component_Data.m deleted file mode 100644 index 88a7cc9..0000000 --- a/src/Process_Imported_Component_Data.m +++ /dev/null @@ -1,76 +0,0 @@ -function [C_Data]=Process_Imported_Component_Data(Component_Data,COMPDATA, FRAGDATA) - -for i=1:size(Component_Data,1) - if isnumeric(Component_Data{i,3})==1 - if strcmp(COMPDATA.C_code(Component_Data{i,3},1),'User_BV')==1 || strcmp(COMPDATA.C_code(Component_Data{i,3},1),'User_MV')==1 - C_id=Component_Data{i,3}; - C_type=222; - C_edp=Component_Data{i,7}; - C_name=Component_Data{i,2}; - save('temp.mat','C_id','C_type','C_edp','C_name'); - waitfor(Module_PredictorData_App); - load('temp.mat','OK'); - if OK~=1 - return - end - delete('temp.mat'); - end - % Component ID - C_Data (i,1)=(Component_Data{i,3}); - IDXF=find(C_Data (i,1)==FRAGDATA.C_ID); - UnitVal = FRAGDATA.DS_UnitVal (IDXF(1,1)); - % Component Location - if strcmp(Component_Data{i,4},'Typ.')==1 - C_Data (i,2)=0; - else - C_Data (i,2)=(Component_Data{i,4}); - end - % Number of Cost Units - C_Data (i,3)=(Component_Data{i,5})/UnitVal; - % Number of Damage States - C_Data (i,4)=(Component_Data{i,6}); - % Level Type - if strcmp(Component_Data{i,8},'Story')==1 - C_Data (i,5)=1; - else - C_Data (i,5)=2; - end - else - if strcmp(COMPDATA.C_code(str2double(Component_Data{i,3}),1),'User_BV')==1 || strcmp(COMPDATA.C_code(str2double(Component_Data{i,3}),1),'User_MV')==1 - C_id = Component_Data{i,3}; - C_type = 222; - C_edp = str2double(Component_Data{i,7}); - C_name = str2double(Component_Data{i,2}); - save('temp.mat','C_id','C_type','C_edp','C_name'); - waitfor(Module_PredictorData_App); - load('temp.mat','OK'); - if OK~=1 - return - end - delete('temp.mat'); - end - % Component ID - C_Data (i,1)=str2double(Component_Data{i,3}); - IDXF=find(C_Data (i,1)==FRAGDATA.C_ID); - UnitVal = FRAGDATA.DS_UnitVal (IDXF(1,1)); - - if strcmp(Component_Data{i,4},'Typ.')==1 - % Component Location - C_Data (i,2)=0; - else - C_Data (i,2)=str2double(Component_Data{i,4}); - end - % Number of Cost Units - C_Data (i,3)=str2double(Component_Data{i,5})/UnitVal; - % Number of Damage States - C_Data (i,4)=str2double(Component_Data{i,6}); - % Level Type - if strcmp(Component_Data{i,8},'Story')==1 - C_Data (i,5)=1; - else - C_Data (i,5)=2; - end - end -end - -end \ No newline at end of file diff --git a/src/Process_Imported_Component_Data.p b/src/Process_Imported_Component_Data.p new file mode 100644 index 0000000..8546d79 Binary files /dev/null and b/src/Process_Imported_Component_Data.p differ diff --git a/src/Report_RepairTime_vs_Realization.m b/src/Report_RepairTime_vs_Realization.m index b774302..f88a571 100644 --- a/src/Report_RepairTime_vs_Realization.m +++ b/src/Report_RepairTime_vs_Realization.m @@ -53,7 +53,8 @@ function Report_RepairTime_vs_Realization(DEAGG_DATA,C_Data,COMPDATA,N_Story,Tim end end end - + MaxTimeStory=sum(MaxTimeStory,1); %% Added August 2024 to fix repair time (sequential vs simultaneous repair of different component types at the same storey/floor); + if TimeModel.SchemeFloor==0; REPAIR_TIME_Per_Ri(Ri,1)=max(sum(MaxTimeStory,2)); end if TimeModel.SchemeFloor==1; REPAIR_TIME_Per_Ri(Ri,1)=max(max(MaxTimeStory,[],2)); end end diff --git a/src/Run_Loss_Code.m b/src/Run_Loss_Code.m deleted file mode 100644 index 6e1e7d8..0000000 --- a/src/Run_Loss_Code.m +++ /dev/null @@ -1,60 +0,0 @@ -function Run_Loss_Code(app) -global MainDirectory ProjectPath ProjectName RunMethodology -clc; -cd (ProjectPath) -load(ProjectName,'ResponseDataStatus','Response_Option','Component_Option','ResultsStatus','RunMethodology','Option5_Type') -cd (MainDirectory) - -if ResponseDataStatus~=1 - warndlg('Response Data is missing!'); - return -end - -if RunMethodology ==1 - if ResultsStatus==1 - cd (ProjectPath) - variableInfo = who('-file', ProjectName); - cd (MainDirectory) - if ismember('COLLAPSE_LOSSES_Per_IM', variableInfo) && ismember('DEMOLITION_LOSSES_Per_IM', variableInfo)&& ismember('DEAGG_COMPONENT_REPAIR_COST', variableInfo) - rmvar(ProjectPath,ProjectName, 'COLLAPSE_LOSSES_Per_IM', 'DEMOLITION_LOSSES_Per_IM','DEAGG_COMPONENT_REPAIR_COST') - cd (MainDirectory) - end - if ismember('STORY_REPAIR_COST', variableInfo) && ismember('STORY_REPAIR_COST_SC', variableInfo)&& ismember('STORY_REPAIR_COST_NSC_SDR', variableInfo)&& ismember('NSC_ACC_REPAIR_COST_PerIM', variableInfo)&& ismember('REPAIR_COST_TOTAL_PerIM', variableInfo)&& ismember('TOTAL_LOSSES_PerIM', variableInfo) - rmvar(ProjectPath,ProjectName, 'STORY_REPAIR_COST','STORY_REPAIR_COST_SC','STORY_REPAIR_COST_NSC_SDR','STORY_REPAIR_COST_NSC_ACC','SC_REPAIR_COST_PerIM','NSC_SDR_REPAIR_COST_PerIM','NSC_ACC_REPAIR_COST_PerIM','REPAIR_COST_TOTAL_PerIM','TOTAL_LOSSES_PerIM') - cd (MainDirectory) - end - end - - if Response_Option~=5; Option5_Type=0; end - - if Response_Option==1 || Option5_Type==1 - if Component_Option==1; LossCode_PEER_CO1_IDA(app); - elseif Component_Option==2; LossCode_PEER_CO2_IDA(app); - elseif Component_Option==3; LossCode_PEER_CO3_IDA(app); - end - else - if Component_Option==1; LossCode_PEER_CO1(app); - elseif Component_Option==2; LossCode_PEER_CO2(app); - elseif Component_Option==3; LossCode_PEER_CO3(app); - end - end -end - -if RunMethodology==2 - if ResultsStatus==1 - cd (ProjectPath) - variableInfo = who('-file', ProjectName); - cd (MainDirectory) - if ismember('COLLAPSE_LOSSES_Per_IM', variableInfo) && ismember('DEMOLITION_LOSSES_Per_IM', variableInfo)&& ismember('DEAGG_DATA', variableInfo) - rmvar(ProjectPath,ProjectName, 'COLLAPSE_LOSSES_Per_IM', 'DEMOLITION_LOSSES_Per_IM','DEAGG_DATA') - cd (MainDirectory) - end - end - - if Component_Option==1; LossCode_FEMAP58_CO1(app); - elseif Component_Option==2; LossCode_FEMAP58_CO2(app); - elseif Component_Option==3; LossCode_FEMAP58_CO3(app); - end -end - -end \ No newline at end of file diff --git a/src/Run_Loss_Code.p b/src/Run_Loss_Code.p new file mode 100644 index 0000000..d0fb901 Binary files /dev/null and b/src/Run_Loss_Code.p differ diff --git a/src/Show_Project_Summary.m b/src/Show_Project_Summary.m deleted file mode 100644 index 06d2fe7..0000000 --- a/src/Show_Project_Summary.m +++ /dev/null @@ -1,7 +0,0 @@ -function []=Show_Project_Summary -clc - -[SummaryText]=Get_Project_Summary; - -Project_Summary_App(SummaryText) - diff --git a/src/Show_Project_Summary.p b/src/Show_Project_Summary.p new file mode 100644 index 0000000..1f148c0 Binary files /dev/null and b/src/Show_Project_Summary.p differ diff --git a/src/Write2File.m b/src/Write2File.m deleted file mode 100644 index 19ea459..0000000 --- a/src/Write2File.m +++ /dev/null @@ -1,24 +0,0 @@ -function Write2File(FileNameX,Xdata,Ydata) -global MainDirectory ProjectPath - -cd (ProjectPath) -fileX = fopen(FileNameX,'wt'); - -fprintf(fileX,'%s\t%s\t\n','X-data ','Y-data '); -fprintf(fileX,'%s\n','-------------------------------------------------------------------------------------------------'); - -if size(Xdata,2)==1 - for i=1:size(Xdata,1) - fprintf(fileX,'%f\t%f\t\n', Xdata(i,1), Ydata(i,1)); - end -else - for i=1:size(Xdata,1) - for j=1:size(Xdata,2) - fprintf(fileX,'%f\t', Xdata(i,j)); - end - fprintf(fileX,'%f\t\n', Ydata(i,1)); - end -end -fclose(fileX); -cd (MainDirectory) -end \ No newline at end of file diff --git a/src/Write2File.p b/src/Write2File.p new file mode 100644 index 0000000..234e281 Binary files /dev/null and b/src/Write2File.p differ diff --git a/src/Write_EDP_Data_2Excel_Option5.m b/src/Write_EDP_Data_2Excel_Option5.m deleted file mode 100644 index 031e6ab..0000000 --- a/src/Write_EDP_Data_2Excel_Option5.m +++ /dev/null @@ -1,21 +0,0 @@ -function Write_EDP_Data_2Excel_Option5(N_GM,N_Story, EDP_Data, MainDirectory, FilePath ,FileName) - -GM_No=(1:N_GM)'; GM_No = table(GM_No); -Story=(1:N_Story); Story = table(Story); -Floor=(1:N_Story+1); Floor = table(Floor); - -cd (FilePath) -writetable(GM_No,FileName,'Sheet','SDR','Range','A2') -writetable(Story,FileName,'Sheet','SDR','Range','B2') -writematrix(EDP_Data.SDR.S1,FileName,'Sheet','SDR','Range','B3') - -writetable(GM_No,FileName,'Sheet','RDR','Range','A2') -writetable(Story,FileName,'Sheet','RDR','Range','B2') -writematrix(EDP_Data.RDR.S1,FileName,'Sheet','RDR','Range','B3') - -writetable(GM_No,FileName,'Sheet','PFA','Range','A2') -writetable(Floor,FileName,'Sheet','PFA','Range','B2') -writematrix(EDP_Data.PFA.S1,FileName,'Sheet','PFA','Range','B3') -cd (MainDirectory) - -end \ No newline at end of file diff --git a/src/Write_EDP_Data_2Excel_Option5.p b/src/Write_EDP_Data_2Excel_Option5.p new file mode 100644 index 0000000..3c09713 Binary files /dev/null and b/src/Write_EDP_Data_2Excel_Option5.p differ diff --git a/src/cent_diff.m b/src/cent_diff.m deleted file mode 100644 index cd65eeb..0000000 --- a/src/cent_diff.m +++ /dev/null @@ -1,85 +0,0 @@ -%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% SDOF solution using Central Difference Method -% -% Developed by: Dimitrios G. Lignos, Ph.D. -% Date: 08/21/2011 -% Last Modified: 08/21/2011 -% -% Input Parameters: -% mass = 1.0 -% Period T -% deltat = time step (equal to time step of the earthquake -% xi = damping ratio -% GMotion -% g: multiples of g in proper units -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -function [Amax] = cent_diff(GMFolderName,period, deltat, xi, GMotion, g) - - mass = 1.0; - -cd (GMFolderName) -% open file to read earthquake data -infile = load(GMotion); -cd .. - -%% Read the ground motion file and put everything in a column vector - -L = length(infile(:,1)); CL = length(infile(1,:)); - -for i=1:L - p((1+(i-1)*CL):(CL+(i-1)*CL),1) = infile(i,:)'*g; -end - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% We now have an array p() which contains L acceleration values -% at an interval of dt sec - - % omega = natural frequency - % stf = stiffness - % damping = "c" - - omega = 2.0*pi/period; - stf = mass*omega*omega; - damp = 2.0*mass*omega*xi; - - - %% Initial Conditions of Central Difference Method - a_prev = p(1)/mass; - u_prev = 0.0; - v_prev = 0.0; - u_pp = a_prev*deltat*deltat/2.0; - - consA = mass/deltat/deltat - damp/(2*deltat); - consB = stf - 2*mass/(deltat*deltat); - kbar = mass/deltat/deltat + damp/(2*deltat); - time(1) = 0.0; - - % u_curr = displacement at step (i+1) - % v_curr = velocity at step (i+1) - % a_curr = acceleration at step (i+1) -%% Calculations for time step i - for i = 2:length(p) - p_curr = p(i) - consA*u_pp - consB*u_prev; - u_curr = p_curr/kbar; - v_curr = (u_curr - u_pp)/(2*deltat); - a_curr = (u_curr - 2*u_prev + u_pp)/(deltat^2); - - dis(i) = 1.*u_curr; -% Spectral Ordinate - aa(i) = ((2*pi/period)^2)*u_curr; - - vv(i) = (2*pi/period)*u_curr; - % store current values into (i-1) for next step - - u_pp = u_prev; - u_prev = u_curr; - v_prev = v_curr; - a_prev = a_curr; - - time(i) = time(i-1) + deltat; - - end - - Amax = max(abs(aa)); \ No newline at end of file diff --git a/src/cent_diff.p b/src/cent_diff.p new file mode 100644 index 0000000..104fa60 Binary files /dev/null and b/src/cent_diff.p differ diff --git a/src/rmvar.m b/src/rmvar.m deleted file mode 100644 index 2f86264..0000000 --- a/src/rmvar.m +++ /dev/null @@ -1,6 +0,0 @@ -function rmvar(ProjectPath,filename, varargin) - -cd (ProjectPath) -error(nargchk(2,inf,nargin)); -vars = rmfield(load(filename),varargin(:)); -save(filename,'-struct','vars'); diff --git a/src/rmvar.p b/src/rmvar.p new file mode 100644 index 0000000..af82192 Binary files /dev/null and b/src/rmvar.p differ diff --git a/src/rotateXLabels.m b/src/rotateXLabels.m deleted file mode 100644 index ac0e6ec..0000000 --- a/src/rotateXLabels.m +++ /dev/null @@ -1,430 +0,0 @@ -function hh = rotateXLabels( ax, angle, varargin ) -%rotateXLabels: rotate any xticklabels -% -% hh = rotateXLabels(ax,angle) rotates all XLabels on axes AX by an angle -% ANGLE (in degrees). Handles to the resulting text objects are returned -% in HH. -% -% hh = rotateXLabels(ax,angle,param,value,...) also allows one or more -% optional parameters to be specified. Possible parameters are: -% 'MaxStringLength' The maximum length of label to show (default inf) -% -% Examples: -% >> bar( hsv(5)+0.05 ) -% >> days = {'Monday','Tuesday','Wednesday','Thursday','Friday'}; -% >> set( gca(), 'XTickLabel', days ) -% >> rotateXLabels( gca(), 45 ) -% -% See also: GCA, BAR - -% Copyright 2006-2013 The MathWorks Ltd. - -error( nargchk( 2, inf, nargin ) ); -if ~isnumeric( angle ) || ~isscalar( angle ) - error( 'RotateXLabels:BadAngle', 'Parameter ANGLE must be a scalar angle in degrees' ) -end -angle = mod( angle, 360 ); - -% From R2014b, rotating labels is built-in using 'XTickLabelRotation' -if ~verLessThan('matlab','8.4.0') - set(ax, 'XTickLabelRotation', angle) - if nargout > 1 - hh = []; - end - return; -end - -[maxStringLength] = parseInputs( varargin{:} ); - -% Get the existing label texts and clear them -[vals, labels] = findAndClearExistingLabels( ax, maxStringLength ); - -% Create the new label texts -h = createNewLabels( ax, vals, labels, angle ); - -% Reposition the axes itself to leave space for the new labels -repositionAxes( ax ); - -% If an X-label is present, move it too -repositionXLabel( ax ); - -% Store angle -setappdata( ax, 'RotateXLabelsAngle', angle ); - -% Only send outputs if requested -if nargout - hh = h; -end - -%-------------------------------------------------------------------------% - function [maxStringLength] = parseInputs( varargin ) - % Parse optional inputs - maxStringLength = inf; - if nargin > 0 - params = varargin(1:2:end); - values = varargin(2:2:end); - if numel( params ) ~= numel( values ) - error( 'RotateXLabels:BadSyntax', 'Optional arguments must be specified as parameter-value pairs.' ); - end - if any( ~cellfun( 'isclass', params, 'char' ) ) - error( 'RotateXLabels:BadSyntax', 'Optional argument names must be specified as strings.' ); - end - for pp=1:numel( params ) - switch upper( params{pp} ) - case 'MAXSTRINGLENGTH' - maxStringLength = values{pp}; - - otherwise - error( 'RotateXLabels:BadParam', 'Optional parameter ''%s'' not recognised.', params{pp} ); - end - end - end - end % parseInputs -%-------------------------------------------------------------------------% - function [vals,labels] = findAndClearExistingLabels( ax, maxStringLength ) - % Get the current tick positions so that we can place our new labels - vals = get( ax, 'XTick' ); - - % Now determine the labels. We look first at for previously rotated labels - % since if there are some the actual labels will be empty. - ex = findall( ax, 'Tag', 'RotatedXTickLabel' ); - if isempty( ex ) - % Store the positions and labels - labels = get( ax, 'XTickLabel' ); - if isempty( labels ) - % No labels! - return - else - if ~iscell(labels) - labels = cellstr(labels); - end - end - % Clear existing labels so that xlabel is in the right position - set( ax, 'XTickLabel', {}, 'XTickMode', 'Manual' ); - setappdata( ax, 'OriginalXTickLabels', labels ); - else - % Labels have already been rotated, so capture them - labels = getappdata( ax, 'OriginalXTickLabels' ); - set(ex, 'DeleteFcn', []); - delete(ex); - end - % Limit the length, if requested - if isfinite( maxStringLength ) - for ll=1:numel( labels ) - if length( labels{ll} ) > maxStringLength - labels{ll} = labels{ll}(1:maxStringLength); - end - end - end - - end % findAndClearExistingLabels -%-------------------------------------------------------------------------% - function restoreDefaultLabels( ax ) - % Restore the default axis behavior - removeListeners( ax ); - - % Try to restore the tick marks and labels - set( ax, 'XTickMode', 'auto', 'XTickLabelMode', 'auto' ); - rmappdata( ax, 'OriginalXTickLabels' ); - - % Try to restore the axes position - if isappdata( ax, 'OriginalAxesPosition' ) - set( ax, 'Position', getappdata( ax, 'OriginalAxesPosition' ) ); - rmappdata( ax, 'OriginalAxesPosition' ); - end - end -%-------------------------------------------------------------------------% - function textLabels = createNewLabels( ax, vals, labels, angle ) - % Work out the ticklabel positions - zlim = get(ax,'ZLim'); - z = zlim(1); - - % We want to work in normalised coords, but this doesn't print - % correctly. Instead we have to work in data units even though it - % makes positioning hard. - y = getYPositionToUse( ax ); - - % Now create new text objects in similar positions. - textLabels = -1*ones( numel( vals ), 1 ); - for ll=1:numel(vals) - textLabels(ll) = text( ... - 'Units', 'Data', ... - 'Position', [vals(ll), y, z], ... - 'String', labels{ll}, ... - 'Parent', ax, ... - 'Clipping', 'off', ... - 'Rotation', angle, ... - 'Tag', 'RotatedXTickLabel', ... - 'UserData', vals(ll)); - end - % So that we can respond to CLA and CLOSE, attach a delete - % callback. We only attach it to one label to save massive numbers - % of callbacks during axes shut-down. - set(textLabels(end), 'DeleteFcn', @onTextLabelDeleted); - - % Now copy font properties into the texts - updateFont(); - % Update the alignment of the text - updateAlignment(); - - end % createNewLabels - -%-------------------------------------------------------------------------% - function repositionAxes( ax ) - % Reposition the axes so that there's room for the labels - % Note that we only do this if the OuterPosition is the thing being - % controlled - if ~strcmpi( get( ax, 'ActivePositionProperty' ), 'OuterPosition' ) - return; - end - - % Work out the maximum height required for the labels - labelHeight = getLabelHeight(ax); - - % Remove listeners while we mess around with things, otherwise we'll - % trigger redraws recursively - removeListeners( ax ); - - % Change to normalized units for the position calculation - oldUnits = get( ax, 'Units' ); - set( ax, 'Units', 'Normalized' ); - - % Not sure why, but the extent seems to be proportional to the height of the axes. - % Correct that now. - set( ax, 'ActivePositionProperty', 'Position' ); - pos = get( ax, 'Position' ); - axesHeight = pos(4); - % Make sure we don't adjust away the axes entirely! - heightAdjust = min( (axesHeight*0.9), labelHeight*axesHeight ); - - % Move the axes - if isappdata( ax, 'OriginalAxesPosition' ) - pos = getappdata( ax, 'OriginalAxesPosition' ); - else - pos = get(ax,'Position'); - setappdata( ax, 'OriginalAxesPosition', pos ); - end - if strcmpi( get( ax, 'XAxisLocation' ), 'Bottom' ) - % Move it up and reduce the height - set( ax, 'Position', pos+[0 heightAdjust 0 -heightAdjust] ) - else - % Just reduce the height - set( ax, 'Position', pos+[0 0 0 -heightAdjust] ) - end - set( ax, 'Units', oldUnits ); - set( ax, 'ActivePositionProperty', 'OuterPosition' ); - - % Make sure we find out if axes properties are changed - addListeners( ax ); - - end % repositionAxes - -%-------------------------------------------------------------------------% - function repositionXLabel( ax ) - % Try to work out where to put the xlabel - removeListeners( ax ); - labelHeight = getLabelHeight(ax); - - % Use the new max extent to move the xlabel. We may also need to - % move the title - xlab = get(ax,'XLabel'); - titleh = get( ax, 'Title' ); - set( [xlab,titleh], 'Units', 'Normalized' ); - if strcmpi( get( ax, 'XAxisLocation' ), 'Top' ) - titleExtent = get( xlab, 'Extent' ); - set( xlab, 'Position', [0.5 1+labelHeight-titleExtent(4) 0] ); - set( titleh, 'Position', [0.5 1+labelHeight 0] ); - else - set( xlab, 'Position', [0.5 -labelHeight 0] ); - set( titleh, 'Position', [0.5 1 0] ); - end - addListeners( ax ); - end % repositionXLabel - -%-------------------------------------------------------------------------% - function height = getLabelHeight(ax) - height = 0; - textLabels = findall( ax, 'Tag', 'RotatedXTickLabel' ); - if isempty(textLabels) - return; - end - oldUnits = get( textLabels(1), 'Units' ); - set( textLabels, 'Units', 'Normalized' ); - for ll=1:numel(vals) - ext = get( textLabels(ll), 'Extent' ); - if ext(4) > height - height = ext(4); - end - end - set( textLabels, 'Units', oldUnits ); - end % getLabelExtent - -%-------------------------------------------------------------------------% - function updateFont() - % Update the rotated text fonts when the axes font changes - properties = { - 'FontName' - 'FontSize' - 'FontAngle' - 'FontWeight' - 'FontUnits' - }; - propertyValues = get( ax, properties ); - textLabels = findall( ax, 'Tag', 'RotatedXTickLabel' ); - set( textLabels, properties, propertyValues ); - end % updateFont - - function updateAlignment() - textLabels = findall( ax, 'Tag', 'RotatedXTickLabel' ); - angle = get( textLabels(1), 'Rotation' ); - % Depending on the angle, we may need to change the alignment. We change - % alignments within 5 degrees of each 90 degree orientation. - if strcmpi( get( ax, 'XAxisLocation' ), 'Top' ) - if 0 <= angle && angle < 5 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom' ); - elseif 5 <= angle && angle < 85 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Bottom' ); - elseif 85 <= angle && angle < 95 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Middle' ); - elseif 95 <= angle && angle < 175 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Top' ); - elseif 175 <= angle && angle < 185 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Top' ); - elseif 185 <= angle && angle < 265 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Top' ); - elseif 265 <= angle && angle < 275 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Middle' ); - elseif 275 <= angle && angle < 355 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Bottom' ); - else % 355-360 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom' ); - end - else - if 0 <= angle && angle < 5 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Top' ); - elseif 5 <= angle && angle < 85 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Top' ); - elseif 85 <= angle && angle < 95 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Middle' ); - elseif 95 <= angle && angle < 175 - set( textLabels, 'HorizontalAlignment', 'Right', 'VerticalAlignment', 'Bottom' ); - elseif 175 <= angle && angle < 185 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Bottom' ); - elseif 185 <= angle && angle < 265 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Bottom' ); - elseif 265 <= angle && angle < 275 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Middle' ); - elseif 275 <= angle && angle < 355 - set( textLabels, 'HorizontalAlignment', 'Left', 'VerticalAlignment', 'Top' ); - else % 355-360 - set( textLabels, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Top' ); - end - end - end - -%-------------------------------------------------------------------------% - function onAxesFontChanged( ~, ~ ) - updateFont(); - repositionAxes( ax ); - repositionXLabel( ax ); - end % onAxesFontChanged - -%-------------------------------------------------------------------------% - function onAxesPositionChanged( ~, ~ ) - % We need to accept the new position, so remove the appdata before - % redrawing - if isappdata( ax, 'OriginalAxesPosition' ) - rmappdata( ax, 'OriginalAxesPosition' ); - end - if isappdata( ax, 'OriginalXLabelPosition' ) - rmappdata( ax, 'OriginalXLabelPosition' ); - end - repositionAxes( ax ); - repositionXLabel( ax ); - end % onAxesPositionChanged - -%-------------------------------------------------------------------------% - function onXAxisLocationChanged( ~, ~ ) - updateAlignment(); - repositionAxes( ax ); - repositionXLabel( ax ); - end % onXAxisLocationChanged - -%-------------------------------------------------------------------------% - function onAxesLimitsChanged( ~, ~ ) - % The limits have moved, so make sure the labels are still ok - textLabels = findall( ax, 'Tag', 'RotatedXTickLabel' ); - xlim = get( ax, 'XLim' ); - pos = [0 getYPositionToUse( ax )]; - for tt=1:numel( textLabels ) - xval = get( textLabels(tt), 'UserData' ); - pos(1) = xval; - % If the tick is off the edge, make it invisible - if xvalxlim(2) - set( textLabels(tt), 'Visible', 'off', 'Position', pos ) - elseif ~strcmpi( get( textLabels(tt), 'Visible' ), 'on' ) - set( textLabels(tt), 'Visible', 'on', 'Position', pos ) - else - % Just set the position - set( textLabels(tt), 'Position', pos ); - end - end - - repositionXLabel( ax ); - end % onAxesPositionChanged - -%-------------------------------------------------------------------------% - function onTextLabelDeleted( ~, ~ ) - % The final text label has been deleted. This is likely from a - % "cla" or "close" call, so we should remove all of our dirty - % hacks. - restoreDefaultLabels(ax); - end - -%-------------------------------------------------------------------------% - function addListeners( ax ) - % Create listeners. We store the array of listeners in the axes to make - % sure that they have the same life-span as the axes they are listening to. - axh = handle( ax ); - listeners = [ - handle.listener( axh, findprop( axh, 'FontName' ), 'PropertyPostSet', @onAxesFontChanged ) - handle.listener( axh, findprop( axh, 'FontSize' ), 'PropertyPostSet', @onAxesFontChanged ) - handle.listener( axh, findprop( axh, 'FontWeight' ), 'PropertyPostSet', @onAxesFontChanged ) - handle.listener( axh, findprop( axh, 'FontAngle' ), 'PropertyPostSet', @onAxesFontChanged ) - handle.listener( axh, findprop( axh, 'FontUnits' ), 'PropertyPostSet', @onAxesFontChanged ) - handle.listener( axh, findprop( axh, 'OuterPosition' ), 'PropertyPostSet', @onAxesPositionChanged ) - handle.listener( axh, findprop( axh, 'XLim' ), 'PropertyPostSet', @onAxesLimitsChanged ) - handle.listener( axh, findprop( axh, 'YLim' ), 'PropertyPostSet', @onAxesLimitsChanged ) - handle.listener( axh, findprop( axh, 'XAxisLocation' ), 'PropertyPostSet', @onXAxisLocationChanged ) - ]; - setappdata( ax, 'RotateXLabelsListeners', listeners ); - end % addListeners - -%-------------------------------------------------------------------------% - function removeListeners( ax ) - % Rempove any property listeners whilst we are fiddling with the axes - if isappdata( ax, 'RotateXLabelsListeners' ) - delete( getappdata( ax, 'RotateXLabelsListeners' ) ); - rmappdata( ax, 'RotateXLabelsListeners' ); - end - end % removeListeners - -%-------------------------------------------------------------------------% - function y = getYPositionToUse( ax ) - % Use the direction and XAxisLocation properties to work out which - % Y-value to draw the labels at. - whichYLim = 1; - % If YDir is reversed, switch where we position - if strcmpi( get( ax, 'YDir' ), 'Reverse' ) - whichYLim = 3-whichYLim; - end - % If set to "top", then switch (again?) - if strcmpi( get( ax, 'XAxisLocation' ), 'Top' ) - whichYLim = 3-whichYLim; - end - % Now get the value - ylim = get( ax, 'YLim' ); - y = ylim(whichYLim); - end % getYPositionToUse - -end % EOF \ No newline at end of file diff --git a/src/rotateXLabels.p b/src/rotateXLabels.p new file mode 100644 index 0000000..4fa3783 Binary files /dev/null and b/src/rotateXLabels.p differ diff --git a/src/v2struct.m b/src/v2struct.m deleted file mode 100644 index bf206fe..0000000 --- a/src/v2struct.m +++ /dev/null @@ -1,362 +0,0 @@ -%% v2struct -% v2struct Pack/Unpack Variables to/from a scalar structure. -function varargout = v2struct(varargin) - -%% Description -% v2struct has dual functionality in packing & unpacking variables into structures and -% vice versa, according to the syntax and inputs. -% -% Function features: -% * Pack variables to structure with enhanced field naming -% * Pack and update variables in existing structure -% * Unpack variables from structure with enhanced variable naming -% * Unpack only specific fields in a structure to variables -% * Unpack without over writing existing variables in work space -% -% In addition to the obvious usage, this function could by highly useful for example in -% working with a function with multiple inputs. Packing variables before the call to -% the function, and unpacking it in the beginning of the function will make the function -% call shorter, more readable, and you would not have to worry about arguments order any -% more. Moreover you could leave the function as it is and you could pass same inputs to -% multiple functions, each of which will use its designated arguments placed in the -% structure. -% -%% Syntax -% Pack -% S = v2struct -% S = v2struct(x,y,z,...) -% S = v2struct(fieldNames) -% S = v2struct(A,B,C,..., fieldNames) -% S = v2struct(x,..., nameOfStruct2Update, fieldNames) -% v2struct -% v2struct(x,y,z,...) -% v2struct(fieldNames) -% v2struct(A,B,C,..., fieldNames) -% v2struct(x,..., nameOfStruct2Update, fieldNames) -% -% Unpack -% v2struct(S) -% [a,b,c,...] = v2struct(S) -% v2struct(S,fieldNames) -% [a,b,c,...] = v2struct(S,fieldNames) -% -%% Inputs & Outputs -% Pack - inputs -% x,y,z,... - any variable to pack. can be replaced by fieldNames below. -% nameOfStruct2Update - optional, name of structure to update if desired. -% fieldNames - optional, cell array of strings, which must include a cell -% with the string 'fieldNames' and must be the last input. -% Pack - outputs -% S - the packed structure. If there is no output argument then a structure named -% Sv2struct would be created in the caller workspace. -% -% Unpack - inputs -% S - name of structure to be unpacked. -% fieldNames - optional, cell array of strings, which must include a cell with the -% string 'fieldNames' and must be the last input. -% Unpack - outputs -% a,b,c,... - variables upacked from the structure. -% if there are no output arguments then variables would be created in -% the caller workspace with naming according to name of inputs. -% -%% Examples -% % see 'Usage example' section below for convenient presentation of these examples. -% -% % NOTE: whenever using filedNames cell array please note the following -% % 1. fieldNames cell array must include a cell with the string 'fieldNames' -% % 2. fieldNames cell array input must be the last input. -% -% % Pack -% x = zeros(3); x2 = ones(3); y = 'Testing123'; z = cell(2,3); -% fieldNames1 = {'fieldNames', 'x', 'y', 'z'}; -% fieldNames2 = {'fieldNames', 'a', 'b', 'c'}; -% fieldNames3 = {'fieldNames', 'x'}; -% nameOfStruct2Update = 'S'; -% -% % The four examples below return structure S with same values however the -% % structure's field names are defined differently in every syntax. -% % Example 1. -% % structure field names defined by variables names. -% S = v2struct(x,y,z) -% % Example 2. -% % structure field names defined according to the cell array fieldNames. -% % NOTE: variables with the names in fieldNames1 must exist in the caller workspace. -% S = v2struct(fieldNames1) -% % Example 3. -% % same as #1. but arguments are passed explicitly -% S = v2struct(zeros(3), 'Testing123', cell(2,3), fieldNames1) -% % Example 4. -% % field names defined by content of fieldNames2 while -% % the values are set according to the passed arguments. In this case the structure -% % S returned would be: S.a=x, S.b=y, S.c=z -% S = v2struct(x,y,z, fieldNames2) -% -% % Example 5. -% % update structure S. The fields that would be updated are according to content -% % of fieldNames3. Note that you must pass a variable with the name -% % 'nameOfStruct2Update' placed before 'fieldNames3'. This variable should contain -% % the name of the structure you want to update as a string. Also note that if you -% % set an output structure name which is different than the one stated in -% % nameOfStruct2Update a new structure would be created and the structure that was -% % meant to be updated would not get updated. -% S.oldField = 'field to be saved for future use' -% S = v2struct(x2, nameOfStruct2Update, fieldNames3) -% -% % Example 6. -% % pack all variables in caller workspace. Call without input arguments. -% S = v2struct -% -% % The following examples return the same results as the examples above but the -% % structure would be returned with the default name 'Sv2struct'. Be cautious as -% % this might lead to overriding of arguments. -% % Example 7. -% v2struct(x,y,z) -% % Example 8. -% v2struct(fieldNames1) -% % Example 9. -% v2struct(zeros(3), 'Testing123', cell(2,3), fieldNames1) -% % Example 10. -% v2struct(x,y,z, fieldNames2) -% % Example 11. -% S.oldField = 'field to be saved for future use' -% v2struct(x2, nameOfStruct2Update, fieldNames3) -% % Example 12. -% v2struct -% -% % Unpack -% clear S x x2 y z fieldNames1 fieldNames2 fieldNames3 nameOfStruct2Update -% S.x = zeros(3); S.y = 'Testing123'; S.z = cell(2,3); -% fieldNames3 = {'fieldNames','x','z'}; -% -% % Example 1. -% % This example creates or overwrites variables x, y, z in the caller with the -% % contents of the corresponding named fields. -% v2struct(S) -% -% % Example 2. -% % This example assigns the contents of the fields of the scalar structure -% % S to the variables a,b,c rather than overwriting variables in the caller. If -% % there are fewer output variables than there are fields in S, the remaining fields -% % are not extracted. -% [a,b,c] = v2struct(S) -% -% % Example 3. -% % This example creates or overwrites variables x and z in the caller with the -% % contents of the corresponding named fields. -% v2struct(S, fieldNames3) -% -% % Example 4. -% % This example assigns the contents of the fields 'x' and 'z' defined by -% % fieldNames3 of the scalar structure S to the variables a and b rather than -% % overwriting variables in the caller. If there are fewer output variables than -% % there are fields in S, the remaining fields are not extracted. -% [a,b] = v2struct(S, fieldNames3) -% -% % This example unpacks variables 'y' and 'z' only without overwriting variable 'x'. -% % NOTE the addition of the field named 'avoidOverWrite' to the structure to be -% % unpacked. This is mandatory in order to make this functionality work. The -% % contents of this field can be anything, it does not matter. -% S.avoidOverWrite = ''; -% x = 'do not overwrite me'; -% v2struct(S) -% -%% Usage example (includes sub-functions) -% 1. run attached v2structDemo1.m file for on screen presentation of examples. -% 2. run attached v2structDemo2.m file and read comments in file for a suggestion of -% how to use v2struct in managing input to other functions with improved usability. -% -%% Revision history -% 2011-05-19, Adi N., Creation -% 2011-05-29, Adi N., Update structure added, some documentation and demo function changes -% 2011-06-02, Adi N., Fixed updating structure functionality -% 2011-06-05, Adi N., Added functionality: avoid overwritring existing variables, added -% unpacking examples to demo1 .m file. -% 2011-06-30, Adi N., fieldNames usage corrected, now must include a specific string to -% be triggered. Documentation enhanced. Code tweaked. -% 2011-07-14, Adi N., Fixed bug in packing with variables only -% 2011-08-14, Adi N., Clarified warning and error when packing/unpacking with -% fieldNames. -% 2011-09-12, Adi N., Added easy packing of all variables in caller workspace (thanks -% to Vesa Lehtinen for the suggestion), fixed bug in warning -% handling in packing case, edited comments. -% -% Inspired by the function: mmv2truct - D.C. Hanselman, University of Maine, Orono, ME -% 04469 4/28/99, 9/29/99, renamed 10/19/99 Mastering MATLAB 5, Prentice Hall, -% ISBN 0-13-858366-8 - - -% parse input for field names -if isempty(varargin) - gotCellArrayOfStrings = false; - toUnpackRegular = false; - toUnpackFieldNames = false; - gotFieldNames = false; -else - gotCellArrayOfStrings = iscellstr(varargin{end}); - - toUnpackRegular = (nargin == 1) && isstruct(varargin{1}); - if toUnpackRegular - fieldNames = fieldnames(varargin{1})'; - nFields = length(fieldNames); - end - - gotFieldNames = gotCellArrayOfStrings & any(strcmpi(varargin{end},'fieldNames')); - if gotFieldNames - fieldNamesRaw = varargin{end}; - % indices of cells with actual field names, leaving out the index to 'fieldNames' cell. - indFieldNames = ~strcmpi(fieldNamesRaw,'fieldNames'); - fieldNames = fieldNamesRaw(indFieldNames); - nFields = length(fieldNames); - end - toUnpackFieldNames = (nargin == 2) && isstruct(varargin{1}) && gotFieldNames; -end - - -% Unpack -if toUnpackRegular || toUnpackFieldNames - - struct = varargin{1}; - assert(isequal(length(struct),1) , 'Single input nust be a scalar structure.'); - CallerWS = evalin('caller','whos'); % arguments in caller work space - - % update fieldNames according to 'avoidOverWrite' flag field. - if isfield(struct,'avoidOverWrite') - indFieldNames = ~ismember(fieldNames,{CallerWS(:).name,'avoidOverWrite'}); - fieldNames = fieldNames(indFieldNames); - nFields = length(fieldNames); - end - - if toUnpackRegular % Unpack with regular fields order - if nargout == 0 % assign in caller - for iField = 1:nFields - assignin('caller',fieldNames{iField},struct.(fieldNames{iField})); - end - else % dump into variables - for iField = 1:nargout - varargout{iField} = struct.(fieldNames{iField}); - end - end - - elseif toUnpackFieldNames % Unpack with fields according to fieldNames - if nargout == 0 % assign in caller, by comparing fields to fieldNames - for iField = 1:nFields - assignin('caller',fieldNames{iField},struct.(fieldNames{iField})); - end - else % dump into variables - assert( isequal(nFields, nargout) , ['Number of output arguments',... - ' does not match number of field names in cell array']); - for iField = 1:nFields - varargout{iField} = struct.(fieldNames{iField}); - end - end - end - -% Pack -else - % build cell array of input names - CallerWS = evalin('caller','whos'); - inputNames = cell(1,nargin); - for iArgin = 1:nargin - inputNames{iArgin} = inputname(iArgin); - end - nInputs = length(inputNames); - - % look for 'nameOfStruct2Update' variable and get the structure name - if ~any(strcmpi(inputNames,'nameOfStruct2Update')) % no nameOfStruct2Update - nameStructArgFound = false; - validVarargin = varargin; - else % nameOfStruct2Update found - nameStructArgFound = true; - nameStructArgLoc = strcmp(inputNames,'nameOfStruct2Update'); - nameOfStruct2Update = varargin{nameStructArgLoc}; - % valid varargin with just the inputs to pack and fieldNames if exists - validVarargin = varargin(~strcmpi(inputNames,'nameOfStruct2Update')); - % valid inputNames with just the inputs name to pack and fieldNames if exists - inputNames = inputNames(~strcmpi(inputNames,'nameOfStruct2Update')); - nInputs = length(inputNames); - % copy structure from caller workspace to enable its updating - if ismember(nameOfStruct2Update,{CallerWS(:).name}) % verify existance - S = evalin('caller',nameOfStruct2Update); - else - error(['Bad input. Structure named ''',nameOfStruct2Update,... - ''' was not found in workspace']) - end - end - - % when there is no input or the input is only variables and perhaps - % also nameOfStruct2Update - if ~gotFieldNames - % no input, pack all of variables in caller workspace - if isequal(nInputs, 0) - for iVar = 1:length(CallerWS) - S.(CallerWS(iVar).name) = evalin('caller',CallerWS(iVar).name); - end - % got input, check input names and pack - else - for iInput = 1:nInputs - if gotCellArrayOfStrings % called with a cell array of strings - errMsg = sprintf(['Bad input in cell array of strings.'... - '\nIf you want to pack (or unpack) using this cell array as'... - ' designated names'... - '\nof the structure''s fields, add a cell with the string'... - ' ''fieldNames'' to it.']); - else - errMsg = sprintf(['Bad input in argument no. ', int2str(iArgin),... - ' - explicit argument.\n'... - 'Explicit arguments can only be called along with a matching'... - '\n''fieldNames'' cell array of strings.']); - end - assert( ~isempty(inputNames{iInput}), errMsg); - S.(inputNames{iInput}) = validVarargin{iInput}; - end - - % issue warning for possible wrong usage when packing with an input of cell array of - % strings as the last input without it containing the string 'fieldNames'. - if gotCellArrayOfStrings - name = inputNames{end}; - % input contains structure and a cell array of strings - if (nargin == 2) && isstruct(varargin{1}) - msgStr = [inputNames{1},''' and ''',inputNames{2},''' were']; - % input contains any arguments with an implicit cell array of strings - else - msgStr = [name, ''' was']; - end - warnMsg = ['V2STRUCT - ''%s packed in the structure.'... - '\nTo avoid this warning do not put ''%s'' as last v2struct input.'... - '\nIf you want to pack (or unpack) using ''%s'' as designated names'... - ' of the'... - '\nstructure''s fields, add a cell with the string ''fieldNames'' to'... - ' ''%s''.']; - fprintf('\n') - warning('MATLAB:V2STRUCT:cellArrayOfStringNotFieldNames',warnMsg,msgStr,... - name,name,name) - end - end - % fieldNames cell array exists in input - elseif gotFieldNames - nVarToPack = length(varargin)-1-double(nameStructArgFound); - if nVarToPack == 0 % no variables to pack - for iField = 1:nFields - S.(fieldNames{iField}) = evalin('caller',fieldNames{iField}); - end - - % else - variables to pack exist - % check for correct number of fields vs. variables to pack - elseif ~isequal(nFields,nVarToPack) - error(['Bad input. Number of strings in fieldNames does not match',... - 'number of input arguments for packing.']) - else - for iField = 1:nFields - S.(fieldNames{iField}) = validVarargin{iField}; - end - end - - end % if ~gotFieldNames - -if nargout == 0 - assignin( 'caller', 'Sv2struct',S ); -else - varargout{1} = S; -end - -end % if nargin diff --git a/src/v2struct.p b/src/v2struct.p new file mode 100644 index 0000000..1433974 Binary files /dev/null and b/src/v2struct.p differ diff --git a/src/write_Error.m b/src/write_Error.m deleted file mode 100644 index 950a09d..0000000 --- a/src/write_Error.m +++ /dev/null @@ -1,18 +0,0 @@ -function write_Error(ME) -global MainDirectory ProjectPath - -cd (ProjectPath) - -xx={ME.stack.line}; -fid = fopen('Error.txt', 'wt'); -fprintf(fid, 'Error Identifier: %s\n', ME.identifier); -fprintf(fid, 'Error Message: %s\n', ME.message); -fprintf(fid, '--------------------------------------------------\n'); -fprintf(fid, 'Error Location:\n'); -fprintf(fid, '----------------\n'); -for i=1:size(xx,2)-2 - fprintf(fid, 'Line %4d in %s\n', xx{1,i}, ME.stack(i).name); -end -fclose(fid); - -cd (MainDirectory) diff --git a/src/write_Error.p b/src/write_Error.p new file mode 100644 index 0000000..c8fb151 Binary files /dev/null and b/src/write_Error.p differ