필터 지우기
필터 지우기

How to remove NaNs from an array between points

조회 수: 1 (최근 30일)
BuMatlab
BuMatlab 2021년 3월 9일
댓글: KSSV 2021년 3월 9일
I have an array consisting of real numbers and NaNs. I'd like to identify the first row where there is a real number, then extract data from that point to when the next NaN occurs. If you see the attached example, I'd like the results to be example(17:43).
Thanks to the community for the help and let me know if I can cleary anything up!
  댓글 수: 1
BuMatlab
BuMatlab 2021년 3월 9일
Sorry - one more item: I'd like the Nans before the first real number row to remain intact - this would mean the results are example(1:43)

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

채택된 답변

KSSV
KSSV 2021년 3월 9일
Read about isnan.
idx = isnan(example);
idr = diff(find([1;diff(idx);1]));
D = mat2cell(example,idr(:),size(example,2));
celldisp(D)
  댓글 수: 2
BuMatlab
BuMatlab 2021년 3월 9일
Thanks, KSSV. It appears the length(D) ~= example(17:43) - any ideas?
KSSV
KSSV 2021년 3월 9일
See D{1}, D{2} etc..
celldisp(D)

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

추가 답변 (0개)

카테고리

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