How to split binary cells and convert them to dec?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
MKM
am 25 Jan. 2022
Beantwortet: Stephen23
am 25 Jan. 2022
I have a cell array consisting of binary 100x1 e.g
{'0100101000101000'}
{'0100101000101000'}
{'0100101000101000'}
...
{'0100101000101000'}
How do i take the first 3 binary from each cell and then convert it into dec?
maybe a cellfun can be helpful here but i do get some errors
I know you can use bin2dec i should expect a 2 for every cell.
Thanks!
0 Kommentare
Akzeptierte Antwort
zhehao.nkd
am 25 Jan. 2022
C{1} = {'0100101000101000'};
C{2} = {'0100101000101000'};
C{3} = {'0100101000101000'};
if C is your original cell, then:
cellfun(@(x) bin2dec(x{1}(1:3)),C)
Is that what you need?
Weitere Antworten (1)
Stephen23
am 25 Jan. 2022
More efficient than using CELLFUN:
C = {'0100101000101000';'0100101000101000';'0100101000101000';'0100101000101000'}
V = [4,2,1]*sscanf(sprintf('%s ',C{:}),'%1d%1d%1d%*d',[3,Inf])
0 Kommentare
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!