I would like to separate the following sample array into 2 arrays. If C contains any of the following strings (red, spoon, fork) within the row, I want to remove the row and put it into a new cell array.
clear allclc% Sample cell array
C = [{'A1';'A3';'A4';'A7'},{'blue';'green';'red';'blue'},{'spoon';'fork';'knife';'cup'},num2cell(rand(4,1))];idx = cellfun(@(x) strcmp(x, 'red', 'spoon','fork'), C(:,:));% Extracted data
C1 = C(idx,:);% Others
C2 = C(~idx,:);
new arrays should look like…
C1 = 'A1' 'blue' 'spoon' [0.6948] 'A3' 'green' 'fork' [0.3171] 'A4' 'red' 'knife' [0.9502]C2 = 'A7' 'blue' 'cup' [0.0344]
Best Answer