Table Find/Replace based on condition (greater than)
조회 수: 40(최근 30일)
표시 이전 댓글
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
댓글 수: 0
채택된 답변
Image Analyst
2019년 11월 23일
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
댓글 수: 3
추가 답변(0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!