How to search and find array in array?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hilal
el 12 de Sept. de 2024
Comentada: Star Strider
el 13 de Sept. de 2024
Hello,
I create an array below;
bigArray = rand(1,150);
bigArray(1,15:19) = [1 1 1 1 1]';
bigArray(1,25:29) = [1 1 1 1 1]';
bigArray(1,75:79) = [1 1 1 1 1]';
bigArray(1,105:109) = [1 1 1 1 1]';
bigArray(1,65) = 1;
bigArray(1,5:6) = [1 1]';
I want to find [1 1 1 1 1]' array indexes. But I run the code;
idx = find(ismember(bigArray,[1 1 1 1 1]'))
I want to see as an output; [15 16 17 18 19 25 26 27 28 29 75 76 77 78 79 105 106 107 108 109]
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Sept. de 2024
The ismember function is doing exactly what it should. You need to examine ‘bigArray’ tto understand its output.
Try this —
bigArray = rand(1,150);
bigArray(1,15:19) = [1 1 1 1 1]';
bigArray(1,25:29) = [1 1 1 1 1]';
bigArray(1,75:79) = [1 1 1 1 1]';
bigArray(1,105:109) = [1 1 1 1 1]';
bigArray(1,65) = 1;
bigArray(1,5:6) = [1 1]';
disp(bigArray)
Lv = ismember(bigArray,[1 1 1 1 1]')
idx = find(Lv)
.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Dictionaries 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!