User`s guide

23 Check Systems Programmatically
23-4
Create a Function for Checking Multiple Systems
The following tutorial guides you through creating and testing a function to run multiple
checks on any model. The function returns the number of failures and warnings.
1
In the MATLAB window, select New > Function.
2
Save the function as run_configuration.m.
3
In the MATLAB Editor, specify [output_args] as [fail, warn].
4
Rename the function run_configuration.
5
Specify input_args to SysList.
6
Inside the function, specify the list of checks to run using the example Model Advisor
configuration file:
fileName = 'slvnvdemo_mdladv_config.mat';
7
Call the ModelAdvisor.run function:
SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName);
8
Determine the number of checks that return warnings and failures:
fail=0;
warn=0;
for i=1:length(SysResultObjArray)
fail = fail + SysResultObjArray{i}.numFail;
warn = warn + SysResultObjArray{i}.numWarn;
end
The function should now look like this:
function [fail, warn] = run_configuration( SysList)
%RUN_CONFIGURATION Check systems with Model Advsior
% Check systems given as input and return number of warnings and
% failures.
fileName = 'slvnvdemo_mdladv_config.mat';
fail=0;
warn=0;
SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName);
for i=1:length(SysResultObjArray)
fail = fail + SysResultObjArray{i}.numFail;
warn = warn + SysResultObjArray{i}.numWarn;
end
end