Documentation Center

  • Trial Software
  • Product Updates

Create a Function for Checking Multiple Systems in Parallel

If you have a Parallel Computing Toolbox™ license and a multicore host machine, you can create the following function to check multiple systems in parallel:

  1. Create the run_configuration function as described in Create a Function for Checking Multiple Systems.

  2. Save the function as run_fast_configuration.m.

  3. In the Editor, change the name of the function to run_fast_configuration.

  4. Add another input to the run_fast_configuration function so that the inputs are now:

    SysList, numParallel
  5. In the function, set 'ParallelMode' to 'On' . When you use with ‘ParallelMode' set to ‘On', MATLAB® automatically creates a parallel pool.

    SysResultObjArray =,'Configuration',fileName,...

    The function should now look like this:

    function [fail, warn] = run_fast_configuration(SysList, numParallel)
    %RUN_FAST_CONFIGURATION Check systems in parallel with Model Advisor
    %   Check systems given as input in parallel on the number of cores
    %   specified as input. Return number of warnings and failures.
    fileName = 'slvnvdemo_mdladv_config.mat';
    SysResultObjArray =,'Configuration',fileName,...
    for i=1:length(SysResultObjArray)
        fail = fail + SysResultObjArray{i}.numFail;
        warn = warn + SysResultObjArray{i}.numWarn;
  6. Save the function.

  7. Test the function. In the MATLAB Command Window, create a list of systems:

    SysList={'sldemo_auto_climatecontrol/Heater Control',...
        'sldemo_auto_climatecontrol/AC Control', 'rtwdemo_iec61508'};
  8. Run run_fast_configuration on the list of systems, specifying numParallel to be the number of cores in your system. For example, the following command specifies two cores:

    % Run on 2 cores
    [failures, warnings] = run_fast_configuration(SysList, 2);
  9. Review the results. Click the Summary Report link to open the Model Advisor Command-Line Summary report.

Was this topic helpful?