필터 지우기
필터 지우기

how can i remove efficiently nan values from columns without deleting the column itself ?

조회 수: 1 (최근 30일)
for ex :
A = 1 2 3
nan 4 nan
nan nan 5
4 5 6
required output
A = 1 2 3
4 4 5
5 6
  댓글 수: 1
James Tursa
James Tursa 2016년 10월 21일
편집: James Tursa 2016년 10월 21일
Your posted matrix result is not rectangular. You can't have this in a numeric matrix. Is this really what you want for an output or is this a typo? I.e., do you really want the resulting columns to potentially have different numbers of elements? (In which case maybe a cell array would be what you want).

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 10월 21일
i0 = ~isnan(A);
ii = sort(i0,'descend');
out = nan(size(A));
out(ii)=A(i0);

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by