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 ModelAdvisor.run function, set 'ParallelMode' to 'On' . When you use ModelAdvisor.run with ‘ParallelMode' set to ‘On', MATLAB® automatically creates a parallel pool.

    SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName,...
        'ParallelMode','On');

    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';
    fail=0;
    warn=0;
    
    SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName,...
        'ParallelMode','On');
    
    for i=1:length(SysResultObjArray)
        fail = fail + SysResultObjArray{i}.numFail;
        warn = warn + SysResultObjArray{i}.numWarn;
    end
    
    end
    
    
    
  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?