image thumbnail

Data Filter Manager

version 1.2.0 (36.7 KB) by Todd Baxter
Filter a set of data through the use of interactive controls.


Updated 25 Jul 2021

View License

PARENT <1x1 container handle>
- Handle to parent container (figure, uipanel, etc.) where control will be placed
DATA <MxN numeric or cell array>
- Matrix containing the data to be filtered, where each column is a
separate data variable
- Matrix must be numeric, where all variables contain all numeric values,
or a cell array, where each variable contains either all numeric or all
string (character vector) values
VARNAMES <1xN or Nx1 cell array of character vectors>
- Names of the N data variables contained in the columns of the data matrix
OBJ <1x1 DataFilterManager object handle>
- The DataFilterManager object provides user interface controls to
interactively create, update, and apply filter criteria to a set of data
- See DataFilter and DataFilterGroup for the specifics of what filter
criteria can be created
- The 'FilterResult' property is an Mx1 logical array that contains
the result of the filter criteria being applied to the data, which
is automatically updated each time a control is interacted with
To create a filter, select the name of a variable from the listbox,
then click the 'Create Filter' push button below it. Filter controls
for that variable will be created below any other existing filter controls.
To update a filter, simply interact with its user interface controls.
Numeric variables are provided with a SliderEditCombo control and
string variables are provided with an edit textbox to set the criteria
that variable will be assessed against. The filter for a variable can
be made more complex by clicking the 'Add Filter' push button, selecting
a logical operator, and specifying another criteria.
The combined filter criteria defined for all variables is automatically
applied each time a control is interacted with. There is an implicit order
of precedence from top-to-bottom, which may differ from what is expected. Use
the toString method to explicitly view the order of precedence. Note, the
DataFilterManager object triggers an 'Updated' event that indicates when the
filter criteria has been applied and the 'FilterResult' property has been updated.
A specialized BoxPanel container from the GUI Layout Toolbox is used to
provide additional interactivity.
To remove the entire filter for a variable, or just one of its criteria,
click the 'x' at the top right.
To minimize (and maximize) the entire filter for a variable, or just one of
its criteria, click the triangle at the top right. This provides the ability
to save space when many filter controls may be displayed. Note, if the HG2
version of the GUI Layout Toolbox is available, then a ScrollingPanel container
is also used, which allows the filter controls to be scrolled through if they
cannot all be displayed at the same time.
The entire filter for a variable can be enabled and disabled by right-clicking
on its "title bar", i.e. where the 'x' and triangle appear. This can be used
to quickly modify the combined filter criteria without having to completely
remove a filter and then re-create it later. The toString method can be used
to view the combined filter criteria currently in effect.
varnames = {'Length', 'Width', 'Height', 'Area', 'Volume', 'Price'};
data = [];
data(:,1) = linspace(10, 500, 50);
data(:,2) = fliplr(linspace(55, 300, 50));
data(:,3) = linspace(11, 60, 50);
data(:,4) = data(:,1) .* data(:,2);
data(:,5) = data(:,1) .* data(:,2) .* data(:,3);
data(:,6) = round(logspace(3, 5, 50));
f = figure;
h = uiextras.HBoxFlex('Parent', f, 'Spacing', 5);
obj = DataFilterManager(h, data, varnames);
hTable = uitable(h, 'Data', data, 'ColumnName', varnames);
set_box_sizes(h, [-1 -2]);
set_box_sizes(h, [200 300], 'minimum');
addlistener(obj, 'Updated', @(src,evnt)set(hTable,'Data',data(src.FilterResult,:)));
GUI Layout Toolbox
HG1 version (R2014a and earlier):
HG2 version (R2014b and later):

Cite As

Todd Baxter (2021). Data Filter Manager (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!