How to make a table for a struct that contains elements with more than one number?

51 ビュー (過去 30 日間)
John
John 2025 年 2 月 5 日 20:12
コメント済み: Walter Roberson 2025 年 2 月 10 日 20:48
A struct is defined and it adds values as going: X.a, X.b, X.c. etc.most of them is a single value, but a few are arrays with multiple values, such as X.g(1), X.g(2), etc.
When convert them to table using:
thetable = array2table(X, 'RowNames', FileName, 'VariableNames', structNames);
fig = uifigure('Name', 'Variable');
uitable(fig, 'X', thetable);
It displays a very long horizontal table with correct display for those of single value elements. But for those array elements, it displays 2Xdouble, 3Xdouble, etc. not numbers.
The questions are:
(1) How to display those array element separately to view every value?
(2) How to rotate the table?
Thank you.

採用された回答

Voss
Voss 2025 年 2 月 5 日 20:36
X = struct('a',1,'b',22,'c',1:3);
FileName = "SoMe/fIlE\NaMe";
thetable = struct2table(X, 'RowNames', FileName);
fig = uifigure('Name', 'Variable');
uitable(fig, 'Data', thetable);
  7 件のコメント
Voss
Voss 2025 年 2 月 10 日 20:45
There don't appear to be any structs in data, only numeric vectors (e.g., "2x1 double", 4.5676, etc.).
Walter Roberson
Walter Roberson 2025 年 2 月 10 日 20:48
What result are you expecting for combining a 2 x 1 double with a 1 x 1 double ?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by