Remove a column if it starts with NaN

Could you please help me find a way to remove a entire column of a matrix if it starts with Nan
Thank you for any help!

답변 (3개)

Image Analyst
Image Analyst 2014년 8월 27일

1 개 추천

Try this:
A = [1 nan 3 nan;
1 5 6 0;
2 2 3 4;
2 5 6 0;
2 6 7 8;
3 1 2 3;
4 1 2 3]
badColumns = isnan(A(1,:)) % Find cols with nan in top row.
fixedA = A(:,~badColumns) % Get all except the bad columns.
Olga
Olga 2014년 8월 27일

0 개 추천

Thank you very much! It worked!

댓글 수: 1

Guillaume
Guillaume 2014년 8월 27일
Whichever answer worked best for you (they're both valid), you should accept. (and you should have commented on instead of creating a new answer)

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 8월 27일

댓글:

2014년 8월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by