Programmatically create annotation with hyperlink

4 次查看(过去 30 天)
Hello,
I have a model in which I would like to include a hyperlink to an excel file that contains more information about the model. The model and excel file are contained within the same Simulink project however I would like to be able to share the project with someone else, but maintain that hyperlink regardless of where they put the project file.
In my project open script I am getting the root directory of the project using ProjectRootDir = fileparts(mfilename('fullpath'));
and I know I can create an annotation programmatically using the methods described here: http://www.mathworks.com/help/simulink/ug/create-an-annotation-programmatically.html
But no where do I see a parameter to enable a hyperlink and create it using a Matlab variable. Is there another way to implement this?
Thanks!
Max

回答(2 个)

Kent Schonert
Kent Schonert 2022-5-24
I found a solution by looking at the properties of a GUI created hyperlink annotation.
hyperlink = 'www.google.com';
displayText = 'Google';
textValue = [...
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' char(13)...
'<html><head><meta name="qrichtext" content="1" /><style type="text/css">' char(13) ...
'p, li { white-space: pre-wrap; }' char(13) ...
'</style></head><body style=" font-family:''Arial''; font-size:10px; font-weight:400; font-style:normal;">' char(13) ...
'<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="' hyperlink '"><span style=" text-decoration: underline; color:#0000ff;">' displayText '</span></a></p></body></html>'];
a = Simulink.Annotation(gcs,textValue);
a.Interpreter = 'rich'
;

Rick Rosson
Rick Rosson 2014-9-15
编辑:Rick Rosson 2014-9-15

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by