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
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.

댓글을 달려면 로그인하십시오.

 채택된 답변

Nick Suttell
Nick Suttell 2013년 8월 1일

0 개 추천

Basically I want to change each value in the matrix from 8 bytes to 1 bit

댓글 수: 1

Jan
Jan 2013년 8월 1일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2013년 8월 1일

0 개 추천

Use fwrite in conjunction with fopen/fclose to write the binary file with your data type.
doc fwrite
For more information.
Jan
Jan 2013년 8월 1일

0 개 추천

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!

Translated by