how to preallocate large logical array
112 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael
el 13 de Mzo. de 2012
Comentada: Image Analyst
el 23 de Jun. de 2018
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
0 comentarios
Respuesta aceptada
Más respuestas (2)
James Tursa
el 13 de Mzo. de 2012
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:
0 comentarios
Ingrid
el 23 de Jun. de 2018
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 comentario
Image Analyst
el 23 de Jun. de 2018
Or use false() as I suggested:
A = false(50, 50, 50, 50, 50);
It's a bit simpler and more direct.
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!