Populate structure array efficiently
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am wondering if this question is too simple and if I am missing something important. How do I efficiently populate a structure array such that
A = 6:10;
and the resulting structure array is
S(1).A = 6;
S(2).A = 7;
...
S(5).A = 10;
Using a loop S is fairly easy to obtain, but there are probably much more efficient ways to do so.
Regards, Anon
0 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2012-8-17
It can be done, but it is not pretty.
S = struct( 'A', num2cell(6:10) )
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!