replace values with nans

4 ビュー (過去 30 日間)
Leela Sai Krishna
Leela Sai Krishna 2019 年 3 月 18 日
コメント済み: Leela Sai Krishna 2019 年 3 月 18 日
I have a matrix data. i applied a condition and i get the idx. i want to replace that idx values with Nans.
plz suggest the process for this.
Thanks....

採用された回答

madhan ravi
madhan ravi 2019 年 3 月 18 日
data(idx)=NaN
  1 件のコメント
Leela Sai Krishna
Leela Sai Krishna 2019 年 3 月 18 日
thanks it works.
actually i want to replace values in matrices with nans whose idx is 1

サインインしてコメントする。

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2019 年 3 月 18 日
Take a look at logical indexing or the function ind2sub
M = randi(10,8,6)
% use indices of elements for which condition is true
idx = find(M > 8)
M(sub2ind(size(M), idx)) = NaN
% use logical indexing (easier in many cases)
M(M < 3) = 999

カテゴリ

Help Center および File ExchangeNaNs についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by