How to turn a 64-bit matrix into a binary matrix
显示 更早的评论
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 个评论
Jan
2013-8-1
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.
采纳的回答
更多回答(2 个)
Sean de Wolski
2013-8-1
Use fwrite in conjunction with fopen/fclose to write the binary file with your data type.
doc fwrite
For more information.
Jan
2013-8-1
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])
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!