I have a .bin file (having only 0's and 1's). And I want to consider 2 bits of the data from the file at a time in an iterative manner till all of the digits are read.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How Do I do it ?
Question Explanation :
Suppose I have text written in binary format as: 0010011110100111
I want to access two bits of data at a time. For example, first I need to access "00" and I'll perform another algortihm then I want to access "10" and so on till all the digits are read.
0 commentaires
Réponses (1)
Walter Roberson
le 1 Août 2022
twobits = fread(fid, [1 2], 'uchar');
This will not be efficient. Unless you have reason to expect that you might run out of memory, read the entire file at the same time, reshape to two rows, and index the columns
3 commentaires
Walter Roberson
le 1 Août 2022
'uchar' always converts exactly one byte per entry. 'char' on the other hand scans the file the first time to try to figure out what encoding it uses, then rewinds and potentially reads multiple bytes per entry, if matlab guessed utf8 or similar and the current byte looks like it might be part of a multi byte sequence.
Voir également
Catégories
En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!