ModelAdvisor.Text

Create Model Advisor text output

Description

ModelAdvisor.Text objects create formatted text for the Model Advisor output.

Creation

Description

example

text = ModelAdvisor.Text(content,attribute) creates a text object for the Model Advisor output.

Input Arguments

expand all

Optional character vector specifying the content of the text object. If content is empty, empty text is output.

Optional cell array of character vectors specifying the formatting of the content. If attribute is empty, the output text has default coloring with no formatting. Possible formatting options include:

  • normal (default) — Text is black and unformatted.

  • bold — Text is bold.

  • italic — Text is italicized.

  • underline — Text is underlined.

  • pass — Text is green.

  • warn — Text is yellow.

  • fail — Text is red.

  • keyword — Text is blue.

  • subscript — Text is subscripted.

  • superscript — Text is superscripted.

Add ASCII and Extended ASCII characters using the MATLAB® char command.

Object Functions

setBoldSpecify bold text
setColorSpecify text color
setHyperlinkSpecify hyperlinked text
setItalicItalicize text
setRetainSpaceReturnRetain spacing and returns in text
setSubscriptSpecify subscripted text
setSuperscriptSpecify superscripted text
setUnderlinedUnderline text

Examples

collapse all

Text is the simplest form of output. You can format text in many different ways.

When you want one type of formatting for all text, use this syntax:

ModelAdvisor.Text(content, {attributes})

To apply multiple types of formatting, you must create several text objects and combine them.

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(' for a uniform appearance in the model.');

result = ([t1, t2, t3, t4, t5]); 

Here is an example of a simple check callback function using the Model Advisor Formatting APIs:

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 for 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 
Introduced in R2006b