display a MATLAB table in a figure

120 Ansichten (letzte 30 Tage)
Ozan
Ozan am 21 Apr. 2023
Kommentiert: VBBV am 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 Kommentare
Ozan
Ozan am 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 am 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]);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

VBBV
VBBV am 21 Apr. 2023
fig = uifigure();
Use uifigure
  1 Kommentar
VBBV
VBBV am 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]);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by