replace values with nans

조회 수: 17 (최근 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일
  댓글 수: 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by