How to group and convert to decimal?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
The output of r is 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1
I want to group every 8 digits and convert to decimal
Please help
4 Commenti
Image Analyst
il 4 Feb 2013
Modificato: Image Analyst
il 4 Feb 2013
You mean an "array" of doubles is returned by r(), like this [0, 0, 0, 1, 0, 1, 0, etc.], not just a single double like you implied. So, it's like what Azzi assumed.
Risposta accettata
Azzi Abdelmalek
il 4 Feb 2013
x=[ 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1]
x=num2str(x)
x(x==' ')=[];
y=reshape(x,[],8);
out=bin2dec(y)
3 Commenti
Azzi Abdelmalek
il 4 Feb 2013
Ok, there is an error in reshape function
x=[ 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1]
x=num2str(x)
x(x==' ')=[];
y=reshape(x,8,[])';
out=bin2dec(y)
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!