Table Find/Replace based on condition (greater than)
6 ビュー (過去 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 件のコメント
Image Analyst
2019 年 11 月 23 日
編集済み: Image Analyst
2021 年 7 月 8 日
What are "w conditionals"?
It is vectorized by column.
The reason I did it by columns is that some columns (not in this case though) might not be numeric, in general. So you can't just convert the whole table to a numerical array, then do the whole matrix vectorized at once, then convert back to a table, unless you know what column numbers are numeric.
Giuseppe Degan Di Dieco
2021 年 7 月 7 日
Dear Image Analyst,
thanks for your tip, easy and straight.
Best.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!