How to turn a 64-bit matrix into a binary matrix
1 view (last 30 days)
Show older comments
I have a matrix that is millions of rows long. It's a matrix of only one's and zero's. I want to turn the value type from 64-bit to binary so that I can store even more rows before my computer runs out of memory. How can I do this?
1 Comment
Jan
on 1 Aug 2013
Why is this bit array store in a 64 bit type? Please post more details, e.g. if it is signed or unsigned, if the neighboring bits are sorted columnwise or rowwise, If the number of rows or columns is a multiple of 8, if you want to modify the resulting array afterwards, etc.
Most likely it is a bad idea to store the bits in such a huge type, instead of choosing a bit-representation directly.
Accepted Answer
Nick Suttell
on 1 Aug 2013
1 Comment
Jan
on 1 Aug 2013
Please do not post information belonging to the question as an answer and accepting an answer signals, that the problem is solved. Therefore I recommend, that you delete this answer, such that others will post further solutions.
More Answers (2)
Sean de Wolski
on 1 Aug 2013
Use fwrite in conjunction with fopen/fclose to write the binary file with your data type.
doc fwrite
For more information.
0 Comments
Jan
on 1 Aug 2013
A standard method for the transformation, but it depends on several details if this matches your problem:
x = uint64(rand(10, 8) > 0.5); % Test data
y = uint8(x) * uint8([1;2;4;8;16;32;64;128])
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!