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!