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!