Large scale linear algebra
조회 수: 1 (최근 30일)
이전 댓글 표시
What function would i use to figure out the memory a matrix uses?
댓글 수: 0
답변 (2개)
Matt J
2021년 5월 31일
편집: Matt J
2021년 5월 31일
whos will work if you want the memory consumption of any variable including its metadata.
A=rand(10);
whos A
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
However, if you were to modify B in any way, Matlab would allocate B it's own 800 bytes.
댓글 수: 2
Matt J
2021년 6월 4일
You're very welcome, but please Accept-click the answer if it resolved your question.
Matt J
2021년 5월 31일
편집: Matt J
2021년 6월 1일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!