N(:, any(cellfun(@(C) eq(C,0), R(:,2))) = [];
Two parts are involved here: one is detecting the zero in a column in one array, and the other is deleting column 1 in another array if the zero was found.
The three steps you use for detection can be merged together by various methods; I show one of them above.
In the above I also managed to merge the deletion into the single step, by using an obscure trick. It would not have worked if it had been anything other than column 1 to be removed, and the adjustment to handle some other arbitrary column would pile obscurity on obscurity. Using an "if" would be much more readable: if any(cellfun(@(C) eq(C,0), R(:,2)); N(:,7) = []; end
Best Answer