Filter löschen
Filter löschen

Memory overload with dec2bin

1 Ansicht (letzte 30 Tage)
andreas
andreas am 8 Jul. 2013
If i try to run this command:
M = dec2bin(0:2^21-1, 21);
I get the following error: "Error using * Out of memory. Type HELP MEMORY for your options."
When trying to run it with 2^20 it still works.
Is there a way to work around that error?
PS: I will have to work with that data later on. Is that even possible?

Akzeptierte Antwort

Jan
Jan am 8 Jul. 2013
This creates the vector 0:2^21-1 as double array at first, which requires 16.777.216 Bytes. Then for each of these values 21 characters a 2 Byte are created, which means additional 88.080.384 Bytes. If this exhausts your memory already, you simply do not have enough RAM. Then either use something like FEX: VChooseKRO to create the output as UINT8 array, which occupies the half size only:
M = VChooseKRO(uint8([0, 1]), 21);
But a much better idea would be to run a 64-bit Matlab version on a 64-bit operating system an installing some more GB of RAM.
  1 Kommentar
andreas
andreas am 10 Jul. 2013
Thank you. I went to another PC and it worked out very well.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by