Finding Continuous missing values (NaN) from a matrix

조회 수: 3 (최근 30일)
vedesh Mohit
vedesh Mohit 2018년 2월 12일
답변: Jos (10584) 2018년 2월 12일
Hey,
I have a matrix (133656x1) that contains hourly wind speeds for fifteen years with random and continuous missing points. I am only focused on the continuous section of the data and would like to know if there is a way to search through the matrix and count the amount of continuous NaN's in the matrix. can you help me?

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2018년 2월 12일
Let A - your vector with nan's
out = sum(diff([0;isnsn(A(:))]) == 1)

Jos (10584)
Jos (10584) 2018년 2월 12일
I am not sure what you mean by " count the amount of continuous NaN's". Do you want know total number of NaN values in X? The number of sections with consecutive NaNs?
X = [1 2 3 NaN NaN 6 7 NaN 9 NaN NaN 12 13]
Q = isnan(X)
N_NaNs = sum(Q) % total number of NaNs in X (=5)
N_NaNsections = sum(diff([false Q])>0) % number of sections with consecutive NaNs (=3)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by