How to read and manipulate binary numbers?
Mostra commenti meno recenti
Hi,
Im currently working with binary numbers within matlab, however they are read into my code as single numbers eg. 10001011 etc. However, I need to break up the code so I can examine different parts. Is there a way of breaking a single number into a 2 or more cell array.
For Example, starting with 10001011
broken up to a 1x4 array of [10 00 10 11]
Id appreciate any help, Thanks! Mark
2 Commenti
Chad Gilbert
il 3 Lug 2013
I'm having trouble imagining why you would need to do this. Are you sure there's no place in your code earlier on (say, when you're reading these data) when it makes more sense to format these? E.g. "a = fscanf(fid,'%c%c',2);" or something of the sort?
Mark
il 3 Lug 2013
Risposta accettata
Più risposte (2)
a = [1 0 0 0 1 0 1 1]
for p=1:(size(a)-1)
b = [b strcat(num2str(a(p)),num2str(a(p+1)))]
end
That should feed zeros as double zeros
KD
Mark
il 3 Lug 2013
0 voti
Categorie
Scopri di più su Matrix Indexing 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!