필터 지우기
필터 지우기

Callback function for uitables with multiple tabs in app designer

조회 수: 31 (최근 30일)
Vignesh Somasundaram
Vignesh Somasundaram 2021년 12월 17일
댓글: Voss 2021년 12월 21일
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
Vignesh Somasundaram
Vignesh Somasundaram 2021년 12월 20일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Voss
Voss 2021년 12월 20일
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
Vignesh Somasundaram
Vignesh Somasundaram 2021년 12월 20일
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 2021년 12월 21일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by