Hi everyone,
lets say I have a cell array and a numeric array like:
Old_Array = {20 , '2' ; 21 , '2' ; 22 , '2,3' ; 25 , '3' ; 28 , '2'};
and
new_Numbers = [18 ; 21 ; 22 ; 32];
What I want, is to some kind of mix those two. If a number of new_Numbers matches with the first column of old_Array, i want to add '4' to the cell in the 2nd column on just that row. If a number of new_Numbers is not matched, i want to add it, with the 2nd column containing the'4' String. The result should look like
New_Array = {18 , '4' ; 20 , '2' ; 21 , '2,4' ; 22 , '2,3,4' ; 25 , '3' ; 28 , '2' ; 32 , '4'};
I wonder if there is a solution not using for loops but [i,j]=ismember(new_Numbers,cell2mat(Old_Array(:,1))) and the logical indexes.
Thanks in advance. Any Help is appreciated! 🙂
Best Answer