Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Finding bit's postions in cell
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ranjit Kumar Chennamchetty
el 14 de Oct. de 2019
Cerrada: MATLAB Answer Bot
el 20 de Ag. de 2021
I have a binary number in a cell. I want to find 1's bit positon in cell. Can anyone help me out here.
val =
'0000000000000000'
'0000000000000010'
'0000000000000011'
'0000000000000111'
'0000000000001000'
'0000000000011010'
'0000000000100000'
'0000000000100001'
'0000000000100010'
'0000000000110100'
'0000000001001100'
'0000000001010101'
'0000000001011001'
'0000001010011010'
'0000001010110010'
'0000001010110110'
'0000001011001100'
'0000001100000110'
'0000001100100000'
'0000001100111100'
'0000001101010100'
'0000001101110010'
'0000001110111011'
'0000001111011011'
'0000001111100000'
'0000010000000000'
'0000010000001000'
Thanks & Regards
0 comentarios
Respuestas (1)
Adam Danz
el 14 de Oct. de 2019
Editada: Adam Danz
el 18 de Oct. de 2019
The data in your question contains what appears to be a cell array of strings (or character arrays) where each string represents a binary number. If your question is how to find the position of each 1 within each string,
onePos = cellfun(@(s)strfind(s,'1'), val, 'UniformOutput', false);
This will produce a cell array of indices. onePos{n} lists the positions of '1's within the nth string of 'val'.
For example, the first row has no 1s so that cell element is empty
onePos{1}
ans =
[]
The 6th row has 1s in the 12th, 13th, and 15th character
onePos{6}
ans =
12 13 15
0 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!