Anyway to Pre-allocate Memory for Struct
2 次查看(过去 30 天)
显示 更早的评论
Is there anyway to pre-allocate memory for a struct?
I have a
1x2 struct with 2 fields.
>> s = struct('Name',0,'Name2',0)
But, it comes up as a 1x1 struct.
0 个评论
回答(3 个)
Walter Roberson
2015-7-17
s = struct('Name',{0,0},'Name2',{0,0});
That is, use a cell array, one entry per struct member.
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!