How to understand the Memory [Maximum posible Array] result ?

24 vues (au cours des 30 derniers jours)
Eric VALETTE
Eric VALETTE le 25 Juin 2018
Modifié(e) : OCDER le 25 Juin 2018
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

Réponse acceptée

OCDER
OCDER le 25 Juin 2018
Modifié(e) : OCDER le 25 Juin 2018
You could use the whos command to determine the size of a variable/array.
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

Plus de réponses (1)

Guillaume
Guillaume le 25 Juin 2018
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.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by