display a MATLAB table in a figure

109 次查看(过去 30 天)
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 个评论
Ozan
Ozan 2023-4-21
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 2023-4-21
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]);

请先登录,再进行评论。

采纳的回答

VBBV
VBBV 2023-4-21
fig = uifigure();
Use uifigure
  1 个评论
VBBV
VBBV 2023-4-21
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]);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by