Main Content

sdo.getModelDependencies

List of model file and path dependencies

    Description

    [dirs,files] = sdo.getModelDependencies(modelname) returns dependencies of a Simulink® model. The dependencies are required for parallel computing of parameter estimation, response optimization, or sensitivity analysis tasks. The model must be open for the dependency analysis.

    sdo.getModelDependencies might not return a complete list of model dependencies; some dependencies are undetectable. To learn more, see Dependency Analyzer Scope and Limitations. If your model has dependencies that are undetected or inaccessible by the parallel pool workers, then add them to the list of model dependencies.

    example

    Examples

    collapse all

    Open the Simulink model.

    openExample("boilerpressure_demo")
    

    Get model dependencies.

    [dirs, files] = sdo.getModelDependencies('boilerpressure_demo');
    

    The paths listed in dirs are the paths to all the file dependencies listed in files.

    Enable parallel computing and add model dependencies.

    opts = sdo.OptimizeOptions;
    opts.UseParallel = true;
    opts.ParallelFileDependencies = files;

    Open the Simulink model.

    openExample("boilerpressure_demo")
    

    Get model dependencies.

    [dirs, files] = sdo.getModelDependencies('boilerpressure_demo');
    

    Append an additional file, filename.m located in 'C:\matlab\work\'

    files = vertcat(files,'C:\matlab\work\filename.m');

    Enable parallel computing and add model dependencies.

    opts = sdo.OptimizeOptions;
    opts.UseParallel = true;
    opts.ParallelFileDependencies = files;

    Using file dependencies is recommended. However, in some cases it can be better to choose path dependencies. For example, if parallel computing is set up on a local multi-core computer, using path dependencies is preferred as using file dependencies creates multiple copies of the dependency files on the local computer. This example shows how to use path dependencies for setting up parallel computing.

    Open the Simulink model.

    openExample("boilerpressure_demo")
    

    Get model dependencies.

    [dirs, files] = sdo.getModelDependencies('boilerpressure_demo');
    

    Add undetected path dependencies.

    dirs = vertcat(dirs,'//hostname/C$/matlab/work');
    

    Replace C:/ with valid network path accessible to remote workers.

    dirs = regexprep(dirs,'C:/','////hostname//C$//');

    Enable parallel computing and add model dependencies.

    opts = sdo.OptimizeOptions;
    opts.UseParallel = true;
    opts.ParallelPathDependencies = dirs;

    Input Arguments

    collapse all

    Model name, specified as a character vector or string. The model must be open.

    Example: 'sdoAircraft'

    Data Types: char | string

    Output Arguments

    collapse all

    Paths that contain model dependencies, returned as a cell array.

    Files that are model dependencies, returned as a cell array.

    The cell array is empty when the model does not have any dependencies or sdo.getModelDependencies does not detect any dependencies.

    Tips

    • files lists the model dependencies, and dirs lists the corresponding paths to these dependencies.

      The model dependencies are required during parallel computing and are made accessible to the parallel pool workers by specifying one of the following:

      • File dependencies: the model dependency files are copied to the parallel pool workers.

        Use files to set the ParallelFileDependencies property of sdo.OptimizeOptions to use for parallel computing.

      • Path dependencies: the paths to the model dependencies are specified to the parallel pool workers.

        Use dirs to set the ParallelPathDependencies property of sdo.OptimizeOptions to use for parallel computing.

    • Modify files and dirs to include dependencies that sdo.getModelDependencies cannot detect.

    • Using file dependencies is recommended, however, in some cases it can be better to choose path dependencies. For example, if parallel computing is set up on a local multi-core computer, using path dependencies is preferred as using file dependencies creates multiple copies of the dependency files on the local computer.

    Version History

    Introduced in R2011b