www.gusucode.com > simulinktest 案例源码程序 matlab代码 > simulinktest/ModelVerificationBlocksOutputExample.m

    %% View Graphical Results From Model Verification Library
% Simulink(R) Test(TM) outputs graphical results of the Model Verification
% block library so you can use the Test Manager or Simulation Data
% Inspector to see when your test assessments pass and fail.

%% 
% In
% addition to warnings or stop-simulation behavior, the graphical results
% show the block evaluation results during simulation.
% Viewing Model Verification block results graphically helps you to:
%
% * Determine the time step when a failure occurs.
% * Debug the model by comparing the verification result with relevant
% signals.
% * Trace failures from the results to the model.

%%
% This example shows how to view outputs from Model Verification blocks in
% the Test Manager or Simulation Data Inspector.

%% Open the Model
% The model contains a verification subsystem |Safety Properties| that
% uses an Assertion block to check whether the system disengages if the
% brake has been applied for
% three time steps. The verification subsystem also uses Simulink(R) Design
% Verifier(TM) blocks.
%
%   open_system(fullfile(matlabroot,'examples','simulinktest',...
%       'sltestCruiseControlDefective'))
open_system(fullfile(matlabroot,'examples','simulinktest','sltestCruiseControlDefective'))
warning off Simulink:blocks:AssertionAssert; %Warning off to avoid lengthy command line output


%% Simulate the Model and View Results in SDI
%   sim('sltestCruiseControlDefective')
sim('sltestCruiseControlDefective');

%%
% After the simulation completes, open SDI. The results show that the
% assertion failed at 0.23 seconds.
%%
%   Simulink.sdi.view

%%
% <<../brake_assertion_sdi_output.png>>

%% Highlight Assertion Block in the Model
% To find the assertion block in the model, right-click 
% *BrakeAssertion* in SDI and select *Highlight in Model*. The block is
% highlighted in the verification subsystem.

%%
% <<../brake_assertion_highlight.png>>

%%
close_system('sltestCruiseControlDefective',0)
warning on Simulink:blocks:AssertionAssert;