display a MATLAB table in a figure

92 vues (au cours des 30 derniers jours)
Ozan
Ozan le 21 Avr 2023
Commenté : VBBV le 21 Avr 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 commentaires
Ozan
Ozan le 21 Avr 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 le 21 Avr 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]);

Connectez-vous pour commenter.

Réponse acceptée

VBBV
VBBV le 21 Avr 2023
fig = uifigure();
Use uifigure
  1 commentaire
VBBV
VBBV le 21 Avr 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]);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by