issuing a warning with details
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nathan Bblanc
am 10 Nov. 2020
Bearbeitet: Adam Danz
am 10 Nov. 2020
I want matlab to issue a warning, with a lot of details. However, i don't want to flood the command propmt. i thought of issuing the warning and then adding an (ofline) link to the relevant documentation. I mean that the user can click on the command prompt and then get to the relevant section. how would I do this?
many thanks
2 Kommentare
Rik
am 10 Nov. 2020
You can use links in such messages, but I'm not sure if you can taget a specific section of a doc page. That might also be subject to change without warning over several releases.
Akzeptierte Antwort
Adam Danz
am 10 Nov. 2020
Bearbeitet: Adam Danz
am 10 Nov. 2020
How to add a hyperlink to warning message
% Define message that will appear when user clicks hyperlink.
explanation = ['Here is a long explanation '...
'that the user can access by clicking '...
'on a hotlink in the command window.'];
% Create the hyperlink
hotlinkcode = sprintf('Click <a href="matlab: disp(''%s'') "> this link </a>', explanation);
% Throw warning that includes hyperlink
warning('Warning message. %s', hotlinkcode)
Here's the result when clicked:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/409470/image.png)
Other hyperlink ideas
- This answer shows how to set up a hyperlink that opens an m-file to a specific line number.
- This answer shows how to insert a hyperlink in a dialog box that opens a website.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!