-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindRepeatedIndices.m
More file actions
26 lines (17 loc) · 1012 Bytes
/
findRepeatedIndices.m
File metadata and controls
26 lines (17 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function repeatedIndices = findRepeatedIndices(species_t)
% Initialize an empty cell array to store the repeated indices
repeatedIndices = {};
% Iterate over each pair of cell arrays
for i = 1:numel(species_t)-1
for j = i+1:numel(species_t)
% Get the current pair of cell arrays
cellArray1 = species_t{i};
cellArray2 = species_t{j};
% Compare the values and find the indices where they are similar
isRepeated = ismember(cellArray1, cellArray2);
% Store the indices of the similar values
repeatedIndices{end+1} = find(isRepeated);
end
end
end
%You can use this function by passing your species_t cell array as an argument. The function will return the indices of the similar values in each pair of cell arrays as a cell array repeatedIndices, where repeatedIndices{i,j} represents the indices of the similar values between species_t{1,i} and species_t{1,j}.