MATLAB: How to programmatically add an annotation/note with a hyperlink to a Stateflow chart

stateflow

How to programmatically add an annotation/note with a hyperlink to a Stateflow chart?

Best Answer

This can be done by the following example code:
>> sfnew
>> rt = sfroot;
>> c = rt.find('-isa','Stateflow.Chart');
>> a = Stateflow.Annotation(c);
>> a.Interpretation = 'RICH';
>> a.Text = '<html><body><a href="www.mathworks.com">try this</a></body></html>'
In all releases (older releases) which use Stateflow.Note instead of Stateflow.Annotation, it is possible to accomplish the same thing, you just have to use
>> a = Stateflow.Note(c);
for the constructor.
If you want to add MATLAB Code to the hyperlink, please modify the above mentioned HTML Code in a.Text.
Here you can find how to do this: