| Simulink® Verification and Validation™ | ![]() |
| On this page… |
|---|
You can use the Model Advisor Formatting API to produce formatted outputs in Model Advisor. The following constructors of the ModelAdvisor class provide the ability to format the output. For more information on each constructor and associated methods, click the link in the Constructor column.
| Constructor | Description |
|---|---|
| ModelAdvisor.Text | Formats element text. |
| ModelAdvisor.Paragraph | Combines elements into paragraph format. |
| ModelAdvisor.List | Creates a list of elements. |
| ModelAdvisor.LineBreak | Adds a line break between elements. |
| ModelAdvisor.Table | Creates a table. |
| ModelAdvisor.Image | Adds an image to the output. |
Text is the simplest form of output, but you can format text in many different ways. The default text formatting is:
Empty
Default color (black)
Unformatted (that is, not bold, italicized, underlined, linked, subscripted, or superscripted)
To change text formatting, use the ModelAdvisor.Text constructor. When you want one type of formatting for all text, you can achieve this using the syntax
ModelAdvisor.Text(content, {attributes})When you want multiple types of formatting, you must build the text, as shown in the next example:
t1 = ModelAdvisor.Text('It is ');
t2 = ModelAdvisor.Text('recommended', {'italic'});
t3 = ModelAdvisor.Text(' to use same font for ');
t4 = ModelAdvisor.Text('blocks', {'bold'});
t5 = ModelAdvisor.Text(' to ensure uniform appearance of model.');
result = [t1, t2, t3, t4, t5];You can add ASCII and Extended ASCII characters using the MATLAB® char command. See the ModelAdvisor.Text constructor reference for more information.
You can create two types of lists, numbered and bulleted. The default list formatting is bulleted. Use the ModelAdvisor.List constructor to create and format lists (see ModelAdvisor.List). You can create lists with indented subsections, formatted as either numbered or bulleted, as shown in the next example:
subList = ModelAdvisor.List();
subList.setType('numbered')
subList.addItem(ModelAdvisor.Text('Sub entry 1', {'pass','bold'}));
subList.addItem(ModelAdvisor.Text('Sub entry 2', {'pass','bold'}));
topList = ModelAdvisor.List();
topList.addItem([ModelAdvisor.Text('Entry level 1',{'keyword','bold'}), subList]);
topList.addItem([ModelAdvisor.Text('Entry level 2',{'keyword','bold'}), subList]);The default table formatting is:
Default color (black)
Left justified
Bold title, row, and column headings
You can change table formatting using the ModelAdvisor.Table constructor (see ModelAdvisor.Table). The following example code creates a subtable within a table, as shown in the figure:
table1 = ModelAdvisor.Table(1,1);
table2 = ModelAdvisor.Table(2,3);
table2.setHeading('Table 2');
table2.setHeadingAlign('center');
table2.setColHeading(1, 'Header 1');
table2.setColHeading(2, 'Header 2');
table2.setColHeading(3, 'Header 3');
table1.setHeading('Table 1');
table1.setEntry(1,1,table2);

Paragraphs need to be handled explicitly because most markup languages do not support line breaks. The default paragraph formatting is:
Empty
Default color (black)
Unformatted, that is, not bold, italicized, underlined, linked, subscripted, or superscripted
Aligned left
If you want to change paragraph formatting, use the ModelAdvisor.Paragraph constructor (see ModelAdvisor.Paragraph).
The following is the example from Simple Check Callback Function, reformatted using the Model Advisor Formatting API.
function result = SampleStyleOneCallback(system)
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
if strcmp(get_param(bdroot(system), 'ScreenColor'),'white')
result = ModelAdvisor.Text('Passed',{'pass'});
mdladvObj.setCheckResultStatus(true);
else
msg1 = ModelAdvisor.Text(...
['It is recommended to select a Simulink window screen color'...
' of white to ensure a readable and printable model. Click ']);
msg2 = ModelAdvisor.Text('here');
msg2.setHyperlink('matlab: set_param(bdroot,''ScreenColor'',''white'')');
msg3 = ModelAdvisor.Text(' to change screen color to white.');
result = [msg1, msg2, msg3];
mdladvObj.setCheckResultStatus(false);
end
![]() | Defining a Process Callback Function | Registering Custom Checks, Tasks, and Groups | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |