Control Table UI Component Appearance and Behavior in MATLAB
Last Updated :
24 Apr, 2025
In this article, we shall discuss how to create UI tables in MATLAB and control their behaviors and appearance by manipulating some basic properties and visuals. UI tables in MATLAB are the graphical form of tabular data. The UI tables can be created using the uitable function.
Syntax
tab = uitable(...parameters...)
The uitable without any parameters generates an empty table. Different parameters could be passed to the same for data modification. We shall not discuss creating UI tables in depth as it is not in this article's scope.
Creating a Basic UI Table
We can create a UI table by passing a prepared data to a uitable component.
Example 1:
Matlab
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen)
tab = uitable(uif,'Data',tab);
In this example, we create a uifigure component which is the only way of converting a table to a uitable in MATLAB R2018a onwards, the same is explained in detail in the following section. Then, we create a table with three variables. After that, the uitable function is called with the uif uifigure component and tab as the 'Data' component.
Output:

This is an example of a simple uitable. We shall use this same table in the following sections to understand the properties of UI tables.
UI Tables in a UI Figure
By default, a new figure is generated by MATLAB for to create a UI table (without any parent figure).
Example 2:
Matlab
% MATLAB Code
tab = uitable;

However, this is not a UI figure component and thus, we cannot add tabular data to such a UI table. The solution for this problem is creating the UI table within a UI figure component. The same can be done by passing the uifigure name to the uitable function.
Matlab
% MATLAB Code
fig = uifigure;
tab = uitable(fig);
In this case, we get a UI figure, which could be developed into an application. The UI table is created inside this UI figure.

As for adding tabular data to this kind of uitable, we have seen the same in previous section.
Column-Width of UI tables
We can modify the column width of uitables in the table definition itself with the following.
Syntax
tab = uitable(uifigure, 'ColumnWidth', {<options>}, 'Data', <data>)
The ColumnWidth could have following four values:
- 'auto' - In this case, MATLAB decides the column width automatically, based on factors such as Column name, longest element, etc. This is the default option.
- 'fit' - This option is only available when a uifigure parent is used. This commands the uitable to fit the columns within the restrictions of the uifigure.
- Ratios - This option for uifigure tables as well. This allows to create columns with widths in ration to each other. The base value is '1x'. Its twice would be '2x', and so on.
- Pixel values - We can pass fixed values for column width in pixel units.
Example 3:
Matlab
% MATLAB Code
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen);
tab = uitable(uif,'ColumnWidth',{29,'fit',39},'Data',tab);
Here, we change the width of all three columns from 'auto' to 29px, 'fit', 39px respectively. The same can be seen below.
Output:

Now, let us see an example where we use the ratio widths.
Example 4:
Matlab
% MATLAB Code
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen);
tab = uitable(uif,'ColumnWidth',{'1x','fit','1x'},'Data',tab);
Output:

As it can be seen, the size of 'fit' is much less than 'auto', which is the case by definition. Another thing to note down is that the width of 'auto' changes with window width however, the width of 'fit' does not change even on changing window width.
Fonts in UI tables
There are various options available for changing the font appearance in a UI table. Discussing them all is not feasible here; therefore, we shall explain the more important ones such as font weight and font angle.
Font weight
Font weight has 2 values, 'normal' and 'bold'. Both have the same meaning as used in ordinary typing. The default option is 'normal'; to change the weight to 'bold' one needs to use the 'FontWeight' option and give its value as 'bold'.
Example 5:
Matlab
% Code
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen);
tab = uitable(uif,'FontWeight','bold','Data',tab);
Output:

As it can be seen, all the fonts are bold now.
Font Angle
This option is generally used to turn the 'italic' font mode on or off. One simply has to use the FontAngle option and pass the argument as 'italic'. This changes all the font to italic.
Example 7:
Matlab
% Code
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen);
tab = uitable(uif,'FontAngle','italic','Data',tab);
Output:

Colors in UI tables
There are two color options available with UI tables in MATLAB, foreground and background. We shall see them both in the following example.
We can change the background and foreground colors by using the 'BackGround' and 'ForeGround' options respectively and then, passing their respective RGB values following them both. The background changes the color of cells whereas the foreground changes the color of font. See the following example for better understanding.
Example 8:
Matlab
% Code
uif = uifigure;
age = [32 ;23; 15; 17; 19];
names = {'Howard';'Harry'; 'Mark'; 'Nik'; 'Mike'};
gen = {'M' ;'M' ; 'M'; 'F'; 'M'};
tab = table(age,names,gen);
tab = uitable(uif,'BackgroundColor',[1 1 0],'ForegroundColor',[0 0.4470 0.7410],'Data',tab);
Here, we change the background to yellow and the foreground (font color) to navy blue color using their respective RGB values.
Output:

As it can be seen, the cell color is yellow, and the font color is a shade of blue.
Similar Reads
Axes Appearance and Behavior in MATLAB
MATLAB offers many types of axes such as polar axes, cartesian axes, etc. The default appearances of these axes are dynamically determined by MATLAB on case-by-case requirements. However, MATLAB does provide its users the option to alter the behavior of these axes, by using some built-in functions.
4 min read
Using Grid Layout to Customize the App Appearance in MATLAB
In this article, we will learn How to Using Grid Layout to Customize the App Appearance in MATLAB Â in this article we will create two app by using the grid layout functionality of MATLAB Â by different methods and we will see how works the grid layout to customize the app appearance in MATLAB. basica
3 min read
How To Add an EditField Component in MATLAB?
An EditField component in MATLAB is a user interface control that allows you to input and edit text. It is a useful tool for creating user-friendly GUI (Graphical User Interface) applications. In this article, we will explain how to add an EditField component to a GUI and show some examples of its u
4 min read
How to create a textarea component in MATLAB
Matlab offers tools for developing GUI applications. It provides functions that can create TextFields, Labels, Buttons, and many more, along with properties to manipulate the components. In this article, we will learn to create a TextArea Component using Matlab. Creating a textarea componentA Text A
4 min read
What are the types of data that control a component ?
A Component is one of the core building blocks of React. In other words, a component is a JavaScript function that takes inputs(props) and returns a React element representing how a UI section should look. Prerequisites:NodeJS or NPMReact JSControlled ComponentsControlled Components: Form data is ha
2 min read
Create a Slider Component in MATLAB
A slider component is a graphical interface that allows the end users to select discrete values in the range of the slider component. MATLAB provides built-in functionalities to create slider components in a MATLAB figure component. This article will explain how to create a slider component in MATLA
3 min read
App Building Components in MATLAB
MATLAB provides an easy-to-implement solution for your ideas. You can represent your ideas in a GUI-friendly way using the MATLAB App Builder. Matlab app builder is very simple to use, which consisted of two parts, i.e., designing and coding part. The best part of Matlab App Builder is its ready-to-
6 min read
How to Create an Image Component in MATLAB?
MATLAB is an extensive tool that provides various options to its users. Creating image components is one of those tools. MATLAB provides simple functions to create image components. The uiimage function creates a new image component in a new figure by calling on the uifigure function. Usage of uiima
2 min read
Explain the benefits of controlled components.
React JS is a powerful library for building user interfaces and utilizing its core concepts will help in the efficient development of websites. One of such concepts is controlled components which play an important role in managing form elements. In this article, we will be studying the "Benefits of
3 min read
Create a Simple App Using GUIDE in MATLAB
MATLAB is a (Matrix-Laboratory), matrix-based programming language platform that is majorly used to solve math work and real-time problems. it's specifically designed for engineers and scientists to analyze and design systems. And also capable to solve real-time problems with some histogram equaliza
3 min read