필터 지우기
필터 지우기

delete nan values and the corresponding value in another array

조회 수: 1 (최근 30일)
Hana
Hana 2015년 1월 13일
댓글: Adam 2015년 1월 13일
I have three arays: I want to plot B(x axis) and C(y axis).if there is a nan in any of A,B or C that cell should be deleted with its corresponding cells in other arrays.
A=[ nan 2 3; 4 3 nan; 5 3 2] B=[ 9 8 7 ;6 nan 5;6 5 8] C=[3 4 nan;4 3 2;5 3 2]
answer: B=[nan 8 nan;6 nan nan;6 5 8] C=[nan 4 nan;4 nan nan;5 3 2]

채택된 답변

Adam
Adam 2015년 1월 13일
nanIdx = find( isnan(A) | isnan(B) | isnan(C) );
A(idx) = NaN; B(idx) = NaN; C(idx) = NaN
  댓글 수: 2
Hana
Hana 2015년 1월 13일
Thanks! How to remove these NaN values?
Adam
Adam 2015년 1월 13일
What do you mean by remove them?
You have a 2d array so unless you use a cell array containing empty cells you can't just get rid of elements of a 2d array while retaining its 2d structure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by