
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Hyperlink Component in MATLAB
In MATLAB, we can use the MATLAB's built-in GUI environment 'App Designer' to create a hyperlink component. The App Designer Environment of MATLAB allows to create several types of GUI components like hyperlink, buttons, sliders, text fields, etc.
To create a hyperlink component in MATLAB, we can use a built-in option 'uihyperlink'. This function creates a GUI hyperlink component in MATLAB. This function allows users to navigate across web resources with a single click. The 'uihyperlink' function creates a hyperlink object in a MATLAB app. The 'uihyperlink' function can have the following syntaxes.
(1). Create Hyperlink Object with Default Properties
Syntax
To create a hyperlink component with default properties, we can use the following syntax of the 'uihyperlink' function ?
hlink = uihyperlink;
This syntax of the 'uihyperlink' function creates a hyperlink component with default properties and display it in a new GUI figure window.
MATLAB Program (1)
The following MATLAB program demonstrates the implementation of this syntax of 'uihyperlink' function.
% Create a hyperlink component with default properties hlink = uihyperlink;
Output
Code Explanation
When we run this MATLAB, it will open a GUI figure window with a hyperlink component 'Hyperlink' displayed in it.
(2). Create a Hyperlink Component in Parent Container
Syntax
The following syntax of the 'uihyperlink' function is used to create a hyperlink component in the parent container ?
hlink = uihyperlink(parent);
Here, we can the parent container can be a figure created by using the 'uifigure' option in MATLAB.
This syntax of the 'uihyperlink' function creates a hyperlink component and places it as a child in the specified parent container.
Matlab Example (2)
The following MATLAB program demonstrates the use of this syntax.
% MATLAB program to create a hyperlink component with parent container % Create a GUI figure container fig = uifigure; % Create a hyperlink component with parent container hlink = uihyperlink(fig);
Output
Code Explanation
This MATLAB code will create a hyperlink component with the text 'Hyperlink' and place it as a child of the figure. Hence, this hyperlink component 'Hyperlink' will be shown within the GUI figure window.
(3). Create a Hyperlink Component with Customized Properties
We can also create a hyperlink component in MATLAB with customized properties. For this, we can use the following syntax of the 'uihyperlink' function ?
hlink = uihyperlink(parent, PropertyName, PropertyValue,?);
In this case, we define custom properties of the hyperlink component by using the name-value pairs.
Matlab Example (3)
The following MATLAB program demonstrates the implementation of this syntax of the 'uihyperlink' function.
% MATLAB code to create a hyperlink component with custom properties % Create a GUI figure as the parent container fig = uifigure; % Create a hyperlink with custom Text and URL hlink = uihyperlink(fig, 'Text', 'Tutorials Point', 'URL', 'https://www.tutorialspoint.com');
Output
Code Explanation
This MATLAB code will create a hyperlink component with a custom text 'Tutorials Point' and URL 'https://www.tutorialspoint.com'. Hence, this hyperlink component will open the Tutorials Point website when clicked.
Example (1) - Create a Hyperlink Component to Redirect the Text to the Specified web Link.
After getting a brief overview of different syntaxes of the 'uihyperlink' function. Let us now discuss some example programs to understand the applications of 'uihyperlink' components.
% MATLAB code to create a hyperlink to connect the text to a specified link % Create a figure window fig = uifigure; % Create a hyperlink component to connect the link and text hlink = uihyperlink(fig, 'Text', 'Tutorials Point', 'URL', 'https://www.tutorialspoint.com', 'Position', [200, 200, 150, 40], 'FontColor', [0, 0.7, 0]);
Output
Explanation
When user will click the link text 'Tutorials Point', he will be redirected to the Tutorials Point website.
Example (2) - Create a Hyperlink Component and Display Custom Tooltip
% MATLAB code to create a hyperlink and display custom tooltip % Create a figure window fig = uifigure; % Create a hyperlink component to display a custom tooltip hlink = uihyperlink(fig, 'Text', 'Tutorials Point', 'URL', 'https://www.tutorialspoint.com', 'Position', [200, 200, 150, 40], 'FontColor', [0, 0.7, 0], 'Tooltip', 'Click to Visit TutorialsPoint');
Output
Explanation
When the user holds their mouse pointer over the hyperlink text 'Tutorials Point', a tooltip showing 'Click to Visit TutorialsPoint' will be displayed.
Example (3) - Create Hyperlink Component to Send an Email
% MATLAB code to create a hyperlink to send an email % Create a figure window fig = uifigure; % Create a hyperlink component to connect the link and text hlink = uihyperlink(fig, 'Text', 'Contact Tutorials Point', 'URL', ['mailto:', '[email protected]'], 'Position', [200, 200, 150, 40]);
Output
Explanation
This MATLAB code will display a figure window containing a hyperlink component 'Contact Tutorials Point'. When user click on this hyperlink component, he will be redirected to a default email service to send an email to Tutorials Point.
Conclusion
This is all about how to create a hyperlink component in MATLAB. In MATLAB, we can use the 'uihyperlink' function to create an interactive hyperlink component. The creation of a hyperlink component for different use cases is explained in the above sections of this article with the help of example programs.