gpt4 book ai didi

memory - 在 MATLAB 中处理大量结构

转载 作者:太空宇宙 更新时间:2023-11-03 19:56:26 24 4
gpt4 key购买 nike

我需要处理大量(数千万)MATLAB 结构;我需要十几个字段,所以我认为内存不会成为问题,直到我发现这个 ( explanation )

>> s=[];
>> s.first=1;
>> whos
Name Size Bytes Class Attributes

s 1x1 132 struct

>> s.second=2;
>> whos
Name Size Bytes Class Attributes

s 1x1 264 struct

>> s.third=3;
>> whos
Name Size Bytes Class Attributes

s 1x1 396 struct

这显然阻止了我使用数千万个更大的结构。

求助于类解决了内存使用问题(每个结构数组 56 字节的标记),但它在对象的构造和销毁方面慢得令人望而却步。

如何创建轻量级(如 C 结构)且速度快的结构?

最佳答案

将这些结构转换为数组,然后通过类提供访问器方法。

关于memory - 在 MATLAB 中处理大量结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/287362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com