display a MATLAB table in a figure

99 ビュー (過去 30 日間)
Ozan
Ozan 2023 年 4 月 21 日
コメント済み: VBBV 2023 年 4 月 21 日
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 Center および File ExchangeDevelop 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