Borrar filtros
Borrar filtros

How much data does an array take?

5 visualizaciones (últimos 30 días)
Alec Bledsoe
Alec Bledsoe el 4 de Nov. de 2023
Comentada: Walter Roberson el 4 de Nov. de 2023
My question is pretty much entirely in the title. I am curious about how matlab stores data and specifically how much data an nxn array takes to store. Is each element of the array an individual 8 byte double so the size is 8*n^2 bytes?

Respuesta aceptada

James Tursa
James Tursa el 4 de Nov. de 2023
Editada: James Tursa el 4 de Nov. de 2023
The data is held in contiguous memory, so yes for a full real double an NxN matrix would take 8*N^2 bytes for the data. Then there is a variable header that contains info such as class, dimensions, data pointers, etc. That takes an additional 132(?) bytes or so per variable. The actual header amount can vary from release to release, and I haven't checked lately what it is currently.
  4 comentarios
Alec Bledsoe
Alec Bledsoe el 4 de Nov. de 2023
Got it thank you. How do I check the header size?
Walter Roberson
Walter Roberson el 4 de Nov. de 2023
https://www.mathworks.com/matlabcentral/answers/2010767-struct-function-in-matlab
My answer there analyzes struct.
96 bytes to describe a variable. 8 bytes pointer to the data. Another 64 bytes to hold the variable name.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by