フィルターのクリア

How can I minimise the memory usage of the cat function

1 回表示 (過去 30 日間)
James Anderson
James Anderson 2013 年 5 月 21 日
I have two very large data sets that I would like to concatenate using the CAT function. For example
A = rand(10000,10000);
B = rand(10000,10000);
C = cat(3,A,B);
Clear A B
My issue is around memory, the code above requires double the memory. Does anyone know a way that I can concatenate without using more memory? My inclination is to look at copy on write, and handle classes, but it is not clear to me if this would work? Thanks!

回答 (2 件)

Iain
Iain 2013 年 5 月 21 日
Why not just create C to start with?
C = rand(10000,10000,2); ?
NB, C requires 1.4Gb of RAM. I suggest you avoid such big variables unless you have good reason.
  1 件のコメント
Iain
Iain 2013 年 5 月 22 日
You could also add A to B, thus:
B(:,:,2) = A;

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


James Anderson
James Anderson 2013 年 5 月 22 日
Hi Iain, thanks for your suggestion. However I have shown a simplified example for a very complicated piece of code. It does not appear at the moment that I can create the concatenated matrix from the start. This is mainly because I would have to pre-allocate the data, and then my memory headroom would be limited for the interim calculations.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by