If two rows have matching values in column A and in column B, I need to delete the row with the value RED. For example:
A B C D1 March-1st 2 RED1 March-1st 3 GREEN3 March-5th 8 GREEN6 March-8th 4 GREEN 2 April-3rd 5 RED2 April-3rd 0 GREEN
Here I would need to delete row 1 and 5 because they have the value RED in column D while they share values in column A and B with another row.
Here's what I have:
[G,GID] = findgroups(T.A,T.B);is_red = strcmp(T.D,"RED");delete_row = false(size(T,1),1);for ii = 1:numel(GID) idx = G == GID{ii}; if nnz(idx) == 1 continue end delete_row(idx & is_red) = true;endT(delete_row,:) = []
The error I am receiving says:
Error using tabular/parenDeleteRow index exceeds table dimensions.Error in ParserT(delete_row,:) = []