uilabel(parent, Name, Value)
Matlab also provides us with the option to pass the value to the component using name-value pairs.
Example:
Matlab
% MATLAB code for uilabel(parent, Name, Value) function % create a figure fig = uifigure; % create a label and pass the figure as parent label = uilabel(fig, 'Text' , 'Enter Fruits Names:' ); |
Output:
We can see that the size of the component is small and hence the text is clipped. We can fix the issue by modifying the size of the label component.
Example:
Matlab
% create a figure fig = uifigure; % create a label and pass the figure as parent label = uilabel(fig, 'Text' , 'Enter Fruits Names:' ); % changing the size of the label.Position(3:4) = [120, 22]; |
Output:
The position property is a 4 valued list where the first 2 values are the positions and the last 2 values are the sizes of the component. In the code above we have changed the value of the last two indices (3:4).
Label component in MATLAB GUI
Matlab is a numeric computing environment that comes with its own programming language. It specializes in technical computing in areas like Science, Engineering, and many others. Matlab also provides the ability to create GUI applications by simply using its functions for various GUI components.
In this article, we will learn about the Label component, how to create one, and its important properties.