How to search and find array in array?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2024-9-12
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dictionaries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!