MATLAB: Replacing specific rows in a matrix.

row replacement

I would like to replace the cells with the following features (those whose types are 9 or 12 and their ID is one of these numbers, 2,11,12). Then I want to replace them with NaN. However, indexB is a vector of 0 s only.
indexB = ( (Type == 9|Type ==12) & (IDscript ==2|IDscript==11|IDscript==12) );
RT(indexB)=NaN;

Best Answer

  • a = xlsread('Book2.xls');
    indexB = (a(:, 2) == 9|a(:, 2) ==12) & (a(:, 6) ==2|a(:, 6)==11|a(:, 6)==12);
    find(indexB)
    This gives me 6 indices: 29, 30, 363, 364, 573 and 574.