efficient extraction of bytes/bits fomr a long list of uint64s
Mostra commenti meno recenti
Dear all,
I have an instrument that generate very long data streams, on the order of 30,000,000 uint64 numbers. For instance:
mem = uint64(rand(30000000,1))
I have to extract specific bits within each of these uint64 in order to read my data. First I need to convert mem to binary for instance with:
tmp = dec2bin(mem,64)
Then I extract a number of bits, e.g.,
val = tmp(:,1:32)
And convert them back to decimal
val = bin2dec(val)
unfortunately this operation takes minutes because of the very long array of values I have and I have to repeat it a few times to extract different values. The execution time of dec2bin and bin2dec is not great or at least not suitable for this specific task.
Do you have any suggestion on how to recover these values in a more efficient way within Matlab?
Kind regards,
Alessandro
1 Commento
Roger Stafford
il 10 Dic 2014
Be aware of a limitation on 'dec2bin' as given in its site
http://www.mathworks.com/help/matlab/ref/dec2bin.html
"str = dec2bin(d) returns the binary representation of d as a string. d must be a nonnegative integer smaller than 2^52."
This apparently means that the upper 12 bits in uint64 integers are not handled properly in the conversion to a string of bits, so you presumably have more worries than just the time of execution.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!