Scripts

This is the entry point for our code, it calls all other relevant functions.

Run_main

Code

 1% Script to import sbtab and run the analyis
 2% clear functions
 3
 4%Get the date and time
 5date_stamp = string(year(datetime)) + "_" + ...
 6    string(month(datetime)) + "_" + string(day(datetime))...
 7    + "__" + string(hour(datetime)) + "_" + string(minute(datetime))...
 8    + "_" + string(round(second(datetime)));
 9
10% Get the folder where the MATLAB code and models are located
11Matlab_main_folder = fileparts(mfilename('fullpath'))+"/";
12Matlab_main_folder = strrep(Matlab_main_folder,"\","/");
13addpath(genpath(Matlab_main_folder));
14mmf.main = Matlab_main_folder;
15
16% Name of the various analysis that can be run with this code
17analysis_options = ["Diagnostics","Parameter Estimation",...
18    "Global Sensitivity Analysis","Reproduce a previous analysis",...
19    "Reproduce the plots of a previous analysis","Import model files"];
20
21% Code for choosing the model and loading the settings files
22[stg,rst,sb] = f_user_input(mmf,analysis_options);
23
24% Get the folder structure used for the model files
25[mmf] = default_folders(stg,mmf,date_stamp);
26
27% Runs the import scripts if chosen in settings
28if stg.import
29    [stg,sb] = f_import(stg,mmf);
30else
31    % Creates a struct based on the sbtab that is used elswhere in the code
32    % and also adds the number of experiments and outputs to the settings
33    % variable
34    if isempty(sb)% check needed for plot reproduction
35        [stg,sb] = f_generate_sbtab_struct(stg,mmf);
36    end
37end
38
39% Runs the Analysis chosen in settings
40if any(contains(analysis_options(1:3),stg.analysis))
41    rst = f_analysis(stg,stg.analysis,mmf,analysis_options);
42end
43% Save Analysis results if chosen in settings
44if stg.save_results
45    f_save_analysis(stg,sb,rst,mmf)
46end
47
48% Plots the results of the analysis, this can be done independently after
49% loading the results of a previously run analysis
50if stg.plot
51    f_plot(rst,stg,mmf)
52    % Save plots results if chosen in settings
53    if stg.save_results
54        f_save_plots(mmf)
55    end
56end

This is the main script from the MATLAB® portion of the workflow. Depending on the configurations on the settings file and choices on the user facing prompts it can call functions to:

It can also reproduce a the calculations of a previous analysis or just its plots.