MATLAB Answers

# Matlab and memory use

조회 수: 2(최근 30일)
F.O 23 Oct 2017
편집: Reza Bonyadi 24 Oct 2017
Hi, How I can compute how much RAM memory this matrix rand(500,500) take?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Cedric Wannaz 23 Oct 2017
편집: Cedric Wannaz 23 Oct 2017
MATLAB default numeric type/class is "double" (for double-precision floating-point) stored on 8 bytes (= 64 bits). Your array will contain 500 x 500 "double" elements, and the size in byte is the number of elements times the size per element in byte, hence:
>> 500 * 500 * 8
ans =
2000000
which is in MB (megabyte):
>> 500 * 500 * 8 / 1e6
ans =
2

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

Reza Bonyadi 23 Oct 2017
편집: Reza Bonyadi 24 Oct 2017
xx= rand(500,500); h=whos('xx');
h.bytes is what you want then. This is an estimate, as there might be some compressions in place during the usage of the variable. Note that, as different variable may have different types (int, double, ...), whos is a good option as it considers the real size and not sensitive to the type. For example, xx=int8(randi(100,500));h=whos('xx');h.bytes gives you 250,000 while the previous example gives you 2,000,000. So you dont need to know how many bytes are considered for each type in Matlab.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by