delete the columns with the last two values equal to NAN
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all, I have a matrix
a=[1 NaN 1 1; 1 1 1 1; NaN NaN NaN 1;NaN NaN 1 NaN ]
How to do the function that deletes the columns whose last two values are NaN? So the a matrix here is expected to be
b=[1 1; 1 1; NaN 1; 1 NaN ]
after the first and second column are deleted from the matrix.
a =
1 NaN 1 1
1 1 1 1
NaN NaN NaN 1
NaN NaN 1 NaN
b =
1 1
1 1
NaN 1
1 NaN
Thank you very much.
댓글 수: 0
채택된 답변
Renato Agurto
2015년 12월 21일
This should do it:
b = a(:, ~isnan(a(end-1,:)) | ~isnan(a(end,:)));
댓글 수: 1
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!