Large scale linear algebra

What function would i use to figure out the memory a matrix uses?

回答 (2 件)

Matt J
Matt J 2021 年 5 月 31 日
編集済み: Matt J 2021 年 5 月 31 日

0 投票

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 件のコメント

Eduardt Petrick
Eduardt Petrick 2021 年 6 月 3 日
thank you
Matt J
Matt J 2021 年 6 月 4 日
You're very welcome, but please Accept-click the answer if it resolved your question.

サインインしてコメントする。

Matt J
Matt J 2021 年 5 月 31 日
編集済み: Matt J 2021 年 6 月 1 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

リリース

R2019a

タグ

質問済み:

2021 年 5 月 31 日

コメント済み:

2021 年 6 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by