Replace NaN with corresponding elements in another array.
조회 수: 6 (최근 30일)
이전 댓글 표시
I can find the locations of all the NaNs in an array, but how can I replace those elements with the corresponding elements of another array.
댓글 수: 0
답변 (1개)
James Tursa
2015년 2월 2일
A = original array with NaNs in it
B = array with desired replacement values
x = isnan(A);
A(x) = B(x);
댓글 수: 2
James Tursa
2015년 2월 5일
The zeros in what resulting array? If you have an array C the same size as A and you want to replace the zeros in C with the corresponding values from A, then use a similar technique as above. E.g.,
x = (C == 0);
C(x) = A(x);
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!