Memory use 5-D matrix

I'm trying to use 5-D matrices in Matlab (version 2012B) but I run out of memory. Following Matlab help section I created a file called memUsed.m and a test.m.
memUsed.m
[usr, sys] = memory;
usr.MemUsedMATLAB
test.m
format short eng;
memUsed
A = 10.24*ones(40,30,40,30,10);
memUsed
B = 10.24*ones(40,30,40,30,10);
memUsed
C = 10.24*ones(40,30,40,30,10);
memUsed
D = 10.24*ones(40,30,40,30,10);
memUsed
E = 10.24*ones(40,30,40,30,10);
memUsed
The matrices are about the size for my problem. This is the output of running test.m
ans =
812.4621e+006
ans =
927.6662e+006
ans =
1.0429e+009
ans =
1.1581e+009
ans =
1.2733e+009
ans =
1.3885e+009
So what I don't understand is that creating matrix A does not require much memory, neither the rest. However when creating matrix B the memory usage goes through the roof. Why is this? Can I fix this somehow?

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 1 月 29 日

0 投票

812.4621e+006 is the same as 8.124621e+008 .
You are starting with 800 megabytes and you are adding a total of about 560 megabytes, ending up wiht about 1389 megabytes. There is no sudden jump in memory use.

1 件のコメント

MC
MC 2019 年 1 月 29 日
Jesus, my bad. Was obvious, moderator can remove the thread:) Thanks

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

カテゴリ

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

製品

リリース

R2012b

質問済み:

MC
2019 年 1 月 29 日

コメント済み:

MC
2019 年 1 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by