Large scale linear algebra

1 visualización (últimos 30 días)
Eduardt Petrick
Eduardt Petrick el 31 de Mayo de 2021
Comentada: Matt J el 4 de Jun. de 2021
What function would i use to figure out the memory a matrix uses?

Respuestas (2)

Matt J
Matt J el 31 de Mayo de 2021
Editada: Matt J el 31 de Mayo de 2021
whos will work if you want the memory consumption of any variable including its metadata.
A=rand(10);
whos A
Name Size Bytes Class Attributes A 10x10 800 double
Note that this doesn't distinguish between deep and shallow copies. So, for example, in the code below, B is not really consuming an additional 800 bytes of memory on top of what A consumes (because it is just a shallow copy of A).
B=A;
whos A B
Name Size Bytes Class Attributes A 10x10 800 double B 10x10 800 double
However, if you were to modify B in any way, Matlab would allocate B it's own 800 bytes.
  2 comentarios
Eduardt Petrick
Eduardt Petrick el 3 de Jun. de 2021
thank you
Matt J
Matt J el 4 de Jun. de 2021
You're very welcome, but please Accept-click the answer if it resolved your question.

Iniciar sesión para comentar.


Matt J
Matt J el 31 de Mayo de 2021
Editada: Matt J el 1 de Jun. de 2021
When you store an MXN real double matrix in full form, you can expect that its matrix data will consume 8*M*N bytes. For a complex matrix, it will be 16*M*N, naturally. In either case, the calculation doesn't include the memory consumed by the variable's metadata.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by