I would like for the results generated with matchIdx to be saved to a matrix of separate vectors. This Idx can then be used as addresses in further manipulations.
The issue is when i try assigning to matchIdx(:,i) I get errors due to size mismatch of the columns.
I hope somebody can help out. Thank you.
data = [1;2;3;3;5;6;6;3;8;8;9;5;6;7;8;9;10];
check = [2;3;5];
for i=1:3
match(:,i) = ismember(data,check(i));
matchIdx = find(match(:,i))
end
It’s not perfectly clear from your question, but I assume you tried
This is not going to work, since
find(match(:,1))andfind(match(:,2))are not guaranteed to be the same length.Would using cell arrays work for you?