MATLAB: Table Find/Replace based on condition (greater than)

conditionismissingtable

Morning, In a table, how can I find values greater than 1 and replace them with NaN?
I know about the ismissing family but it does not allow (I think) for a condition (greater than), only for specific number/text.
T = table([0.1;0.2],[7;0.5],'VariableNames',{'varx1','varx2'})
The entry "7" should be NaN

Best Answer

Try this:
T = table([0.1;0.2],[7;0.5],'VariableNames',{'varx1','varx2'})
rowsToChange = T.varx1 > 1
if ~isempty(rowsToChange)
T.varx1(rowsToChange) = nan
end
rowsToChange = T.varx2 > 1
if ~isempty(rowsToChange)
T.varx2(rowsToChange) = nan
end