Matlab cell size is much larger than actual data

I recently discovered the strange behavior of MATLAB cell arrays, which was not the case before.

If I create an array of cells with

a=cell(1,4)

its size is 32 bytes.

If then I put something inside, for example.

a{2}='abcd'

its size becomes 144 bytes. But if I delete this content by setting

a{2}=[]

the size becomes 132 bytes, etc. What is the problem?

+4
source share
2 answers

Simply put, the Matlab cell matrix needs some internal data structures to keep track of what is stored internally.

It seems that Matlab allocates memory as needed and thus extends the memory needed by the array of cells when you insert data.

, Matlab - , -, , , ( ), , , "" , , .

: Matlab , (, , ). , Matlab, . ..

, , , ​​ Matlab , - Matlab - , Mathworks Matlab python, , Matlab ; Matlab, , python /.

, , Matlab , , / .

, , , , , , , Matlab ( , Matlab python).

+7

a{2}=[]

"" . , . ( Matlab ...)

( , ):

a(2) = cell(1,1)

"empty" = 32 .

0

Source: https://habr.com/ru/post/1610146/


All Articles