フィルターのクリア

how to preallocate large logical array

113 ビュー (過去 30 日間)
Michael
Michael 2012 年 3 月 13 日
コメント済み: Image Analyst 2018 年 6 月 23 日
Hi
I'm trying to pre-allocate a huge logical matrix but I can't work out how to do it without creating a normal matrix then converting it (this intermediate step uses too much memory).
I've been trying A = zeros(50,50,50,50,50, 'uint8'); Which works to create one from 0-255 but I can't find what to write in the quotes to make it logical rather than numeric, and suspect there may be some kind of trick that I'm missing.
Thanks Mike

採用された回答

Image Analyst
Image Analyst 2012 年 3 月 13 日
A = false(numRows, numCols); % Or can use true()
  1 件のコメント
Michael
Michael 2012 年 3 月 13 日
perfect, thanks

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

その他の回答 (2 件)

James Tursa
James Tursa 2012 年 3 月 13 日
Another alternative (assumes that all of the elements are filled in downstream):
A = uninit(numRows, numCols, 'logical');
You can find uninit on the FEX here:

Ingrid
Ingrid 2018 年 6 月 23 日
I am not sure in which release it started working but at least in R2018a
A = zeros(50,50,50,50,50, 'logical');
works.
  1 件のコメント
Image Analyst
Image Analyst 2018 年 6 月 23 日
Or use false() as I suggested:
A = false(50, 50, 50, 50, 50);
It's a bit simpler and more direct.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by