MATLAB: How to modify table elements without using a for loop

tableupdate table

E.g.
% t is a table
for (yy = 1:size(t,1))
if strcmp('cat',t.animal(yy))
t.value(yy) = t.value(yy)*-1;
end
end

Best Answer

Your original idea of using strcmp was perfect, there is no need to complicate things with strings:
value = [1;2;3;4]
animal = {'cat';'dog';'cat';'dog'}
t = table(value,animal)
idx = strcmp(t.animal,'cat')
t.value(idx) = -t.value(idx)