Hyperlink to PDF in Matlab plot

5 views (last 30 days)
Daniel Liberman
Daniel Liberman on 10 Mar 2020
Answered: Daksh on 2 Feb 2023
Hi, I have a GUI in which the user opens 4 popupmenus one after another and then is asked to enter coordinates and diameters of multiple circles. After doing this, the GUI presents a plot of the circles. I would like to add hyperlinks to the plots so the for each circle, a different PDF/word/text file is opened. The file should be also different for every selection of choices in the popupmenus How can I do that?

Answers (1)

Daksh
Daksh on 2 Feb 2023
I understand you have a GUI figure with plots in MATLAB for which you intend to attach hyperlinks to PDFs or other files available.
You can do so by adding "uibutton" in GUI figure, and then writing a MATLAB function for action when button is pressed. Inside the method call, you can open the PDF file link and this can serve as a hyperlink. You can also add multiple buttons of different shapes, sizes and forms and configure method calls for each of them
Here is an example
function buttonPlot
% Create a figure window
fig = uifigure;
% Create a push button
btn = uibutton(fig,'push',...
'Position',[420, 218, 100, 22],...
'ButtonPushedFcn', @(btn,event) plotButtonPushed(btn));
end
% Create the function for the ButtonPushedFcn callback, which opens
% "file101.pdf", a dummy pdf to be opened
function plotButtonPushed(btn)
disp("Opening relevant PDF file")
open('file101.pdf');
end
Hope this helps!

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!