Display a struct as a table
显示 更早的评论
Hi all,
I have a struct. I want to display the content of this struct as a table. So I use the following transformation.
aTable = struct2table(aStruct);
disp(aTable);
We can see the value of modifiedTime is not correct. I hope to display it as a value, not as an array. Can you tell me how I can do it?
Thanks.
aStruct =
LocalName: {'example.cdf'}
Size: '1 KB'
ModifiedTime: '10-May-2010 21:35:00'
LocalName Size ModifiedTime
_____________ ____ ____________
'example.cdf' 1 KB [1x20 char]
1 个评论
Matthew Eicholtz
2016-2-5
I'm not sure why the display ends up looking like that, but for what it's worth, it displayed ModifiedTime correctly when I added additional entries (e.g. S(2).LocalName = 'test',...).
采纳的回答
更多回答(1 个)
Andrei
2018-4-30
Using struct2table with the 'AsArray' true option produces the desired behavior:
T = struct2table(S, 'AsArray', true);
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!