Saving integer as a bit
Show older comments
I have an array which contains only 0s and 1s. Each data pt is getting saved as an 8 bit integer. How do I save it as a bit to save my memory space?
Answers (2)
Andrei Bobrov
on 11 Apr 2012
in your case use logical array
a1 = randi([0 1],10));
a2 = logical(a1);
1 Comment
Naved Patanwala
on 11 Apr 2012
Mohammad Reza Naderi
on 29 Jul 2020
0 votes
fwrite(fileID,A,precision,skip) Use fwrite for this work. https://www.mathworks.com/help/matlab/ref/fwrite.html#d120e398961
1 Comment
Mohammad Reza Naderi
on 29 Jul 2020
If you want to save with specific precision use instead of precision ubitn
Categories
Find more on Whos in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!