Borrar filtros
Borrar filtros

Callback function for uitables with multiple tabs in app designer

31 visualizaciones (últimos 30 días)
Vignesh Somasundaram
Vignesh Somasundaram el 17 de Dic. de 2021
Comentada: Voss el 21 de Dic. de 2021
Hello developers!!
I am working on a UI which creates a UItable with multiple tabs based on some criteria from a text file.
The function with which I am creating that is as follows:
--> First the tab group is created using
--> Second each tab is names uniquely from an array of strings
app.TabGroup = uitabgroup('Parent', app.UIFigure, 'Position', [20, 20, 100, 150], 'SelectionChangedFcn',{@tabChanged, app.UIFigure});
for n=1:numel(arrayOfNames)
value = char(arrayOfName(n))
tab.(['t' num2str(n)]) = uitab(app.TabGroup,'Title', [value]);
end
--> Thirdly, for each and every tab a table is created and the values are pushed into the individual tabs
timeTableMat = table(matrix1, matrix2, 'VariableNames', variableNames); % matrix1 and matrix2 are temporary variables which have a vector of time and some sensor values
table1 = uitable(tab.(['t' num2str(n)]), 'Data', timeTableMat);
So I am able to create the tabs and tables in each and every tab, but the issue I am facing is with the selectionConditionFcn. When ever I click a new tab, I get an error of the following:
Undefined function 'tabChanged' for input arguments of type 'matlab.ui.container.TabGroup'.
Error using matlab.ui.internal.WebTabGroupController/handlePropertyUpdate (line 113)
Error while evaluating TabGroup SelectionChangedFcn.
As I understand I am missing a basic concept, can any one help me in this regard to resolve this or direct mw towards the right concept?
Other Nuisances:
Where 't' num2str(n) is the tab number and [value] is a string which is containing the name of the tab.
My main aim is to create an axis upon a new tab is selected. The plot is for individual tabs.
There are two columns of data in every tab. I would like to plot those data upon selecting the individual tabs. I would really appreciate some help in getting to know how to create such a selection event for this case.
In a nut shell I am lost in linking the selectionchangedFcn with the tabGroup function.
thanks in advance
  1 comentario
Vignesh Somasundaram
Vignesh Somasundaram el 20 de Dic. de 2021
It would also be helpful, if we are able to pass on the individual tab values (the table each and every tab contains) to the tabChanged function so that it can be processes for graphs and plots.

Iniciar sesión para comentar.

Respuestas (1)

Voss
Voss el 20 de Dic. de 2021
app.TabGroup = uitabgroup('Parent', app.UIFigure, 'Position', [20, 20, 100, 150], 'SelectionChangedFcn',{@tabChanged, app.UIFigure});
This line creates the tab group and sets the 'SelectionChangedFcn' of the tab group to be the function 'tabChanged'.
You have to write the function 'tabChanged' yourself and have it be somewhere the app will find it, either with the rest of the app code or somewhere on the MATLAB path.
And the function 'tabChanged' will need to be able to access the uitabs and uitables in your app, which it's not clear from the code snippets above whether that is the case yet.
  2 comentarios
Vignesh Somasundaram
Vignesh Somasundaram el 20 de Dic. de 2021
should the tanChanged function be within this function where I have created the tab or can it be anywhere in the code editor ?
function tabChanged(src, event)
disp('Tab changed..');
disp(src.SelectedTab);
disp(event)
end
Voss
Voss el 21 de Dic. de 2021
I think wherever works, works. I don't use AppDesigner, so I don't know what kind of constraints there are. Try different things and try to figure out whatever any errors or warnings you might get are telling you, and follow their instructions. Once you know how to set up one callback, you can set up all of them the same way.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by