how to get character from an array using another logical array?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mithushan Kanthasamy
el 18 de Sept. de 2020
Comentada: Mithushan Kanthasamy
el 18 de Sept. de 2020
how to get character from an array using another logical array?
for example
V = '1b.%291x g'
'yig&aaSgwa'
'tqtbbs!?R!'
logicalVec = [ 1 0 1 0 1 0 1 0 1 1; 0 1 1 0 1 0 0 0 1 1; 1 0 1 0 0 1 1 1 0 1]
0 comentarios
Respuesta aceptada
Turlough Hughes
el 18 de Sept. de 2020
A slight modification on your inputs:
V = ['1b.%291x g'; 'yig&aaSgwa'; 'tqtbbs!?R!'];
logicalVec = logical([ 1 0 1 0 1 0 1 0 1 1; 0 1 1 0 1 0 0 0 1 1; 1 0 1 0 0 1 1 1 0 1]);
You can then use a logical index to find the characters corresponding to true values:
V(logicalVec).'
3 comentarios
Walter Roberson
el 18 de Sept. de 2020
To extract "across" instead of "down",
Vt = V.';
Vt(logicalVec.')
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!