How to understand the Memory [Maximum posible Array] result ?
9 次查看(过去 30 天)
显示 更早的评论
Hello, Please could someone help me knowing more about the topic below ?
Function Memory(), output Maximum Posible Array: It is said on the description page ”To see how many array elements this number represents, divide by the number of bytes in the array class. For example, for a double array, divide by 8. The actual number of elements MATLAB can create is always fewer than this number.” How do we know the “number of bytes in the array class” ? For example, for a multiple dimensional matrix 3x3x3, how many bytes consume each cell (type floating and integer values)?
Thank you in advance for your help, hoping you're having a good day. Eric
0 个评论
采纳的回答
OCDER
2018-6-25
编辑:OCDER
2018-6-25
You could use the whos command to determine the size of a variable/array.
Here's a site about memory allocation: https://www.mathworks.com/help/matlab/matlab_prog/memory-allocation.html
IntNum = int8(0);
CellInt = {IntNum};
DoubleNum = 0;
CellDouble = {DoubleNum};
whos
Name Size Bytes Class Attributes
CellDouble 1x1 120 cell
CellInt 1x1 113 cell
DoubleNum 1x1 8 double
IntNum 1x1 1 int8
0 个评论
更多回答(1 个)
Guillaume
2018-6-25
As per the documentation you've quoted each element of a double array uses 8 bytes. So a 3x3x3 double array would be 27x8 = 216 bytes. The same array of type single, which uses 4 bytes per elements would be 27x4 = 108 bytes.
An array of type int64 or uint64 also uses 8 bytes per element. Type int32 or uint32 is 4 bytes, *int16 half of that and *int8 only 1 byte.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!