Customize Diagnostic Messages
TheDiagnostic Viewerdisplays the output of MATLAB®error functions executed during simulation.
You can customize simulation error messages in the following ways by using MATLAB error functions in callbacks, S-functions, orMATLAB Functionblocks.
Display Custom Text
This example shows how to can customize the MATLAB functioncheck_signal
to display the textSignal is negative
.
Open theMATLAB Functionfor editing.
In the MATLAB Editor, create a function to display custom text.
function y = check_signal(x) if x < 0 error('Signal is negative'); else y = x; end
Simulate the model.
A runtime error appears and you are prompted to start the debugger. ClickOK.
To view the following error inDiagnostic Viewer, close the debugger.
Create Hyperlinks to Files, Folders, or Blocks
To create hyperlinks to files, folders, or blocks in an error message, include the path to these items within customized text.
Example error message | Hyperlink |
---|---|
error ('Error reading data from "C:/Work/designData.mat"') |
OpensdesignData.data in the MATLAB Editor. |
error ('Could not find data in folder "C:/Work"') |
Opens a Command Window and setsC:\Work as the working folder. |
error ('Error evaluating parameter in block "myModel/Mu"') |
Displays the blockMu in modelmyModel . |
Create Programmatic Hyperlinks
This example shows how to can customize the MATLAB functioncheck_signal
to display a hyperlink to the documentation forfind_system
.
Open theMATLAB Functionfor editing.
In the MATLAB Editor, create a function to display custom text.
function y = check_signal(x) if x < 0 error('See help for find_system'); else y = x; end
Simulate the model.
A runtime error appears and you are prompted to start the debugger. ClickOK.
To view the following error inDiagnostic Viewer, close the debugger.