display a MATLAB table in a figure

87 views (last 30 days)
Ozan
Ozan on 21 Apr 2023
Commented: VBBV on 21 Apr 2023
I want to output a very simple table in a figure. After a little research the function uitable(..) seems to be well suited for this. I have written the following test code:
uitable_id = strings(1,3);
uitable_links = strings(1,3);
uitable_id(1,:) = ["1", "2", "3"];
uitable_links(1,:) = ["string1", "string1", "string1"];
T = table(uitable_links','RowNames',uitable_id');
fig = figure();
uitable(fig,'Data',T,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);
However, I get the following error message:
Error using uitable
Functionality not supported with figures created with the figure function.
I already looked at other questions and couldnt solve my problem.
  2 Comments
Ozan
Ozan on 21 Apr 2023
Thank you for the quick feedback. The test script works this way. However, if I implement this in my actual scripts as well, a similar error message appears again:
Error using appwindowfactory
Functionality not supported with figures created with the uifigure function.
The only relevant difference from the test script is that my actual scripts work within a MATLAB App Designer environment. From MATALB App Designer external MATLAB scripts are started, which should create these figures. Does MATALB App Designer affect uifigure and my actual goal of creating a table in a figure?
VBBV
VBBV on 21 Apr 2023
Ok, It is probably due to syntax on how the uifigure is called inside the app.
Try using below inside the app designer code
% app.UIFigure
fig = app.UIFigure;
uitable_id = strings(1,3);
uitable_links = strings(1,3);
uitable_id(1,:) = ["1", "2", "3"];
uitable_links(1,:) = ["string1", "string1", "string1"];
T = table(uitable_links','RowNames',uitable_id');
uitable(fig,'Data',T,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);

Sign in to comment.

Accepted Answer

VBBV
VBBV on 21 Apr 2023
fig = uifigure();
Use uifigure
  1 Comment
VBBV
VBBV on 21 Apr 2023
uitable_id = strings(1,3);
uitable_links = strings(1,3);
uitable_id(1,:) = ["1", "2", "3"];
uitable_links(1,:) = ["string1", "string1", "string1"];
T = table(uitable_links','RowNames',uitable_id');
fig = uifigure();
uitable(fig,'Data',T,'Units', 'Normalized', 'Position',[0, 0, 1, 1]);

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!