Something like reshape but accounting for missing values

조회 수: 1 (최근 30일)
Daniel
Daniel 2020년 1월 20일
댓글: Daniel 2020년 1월 20일
I have a columnwise array of x- and y-coordinates with values at those x,y pairs. The full set of coordinates is predetermined and known, but in this array there isn't a value at every x,y pair. When there's no value, it's just skipped, so the original array cannot be rearranged using reshape. For example, the original array may look like this
x1 y3 v13
x2 y2 v22
x2 y3 v23
x3 y1 v31
x3 y2 v32
x3 y3 v33
and I want this
NaN NaN v31
NaN v22 v32
v13 v23 v33
I want to rearrange this original array to put the values in an array whose size is determined by the full set of coordinates with NaNs where there are missing values, and I want it to be fast. It'd be kind of like reshape, except, because there are missing (not empty) values, I don't want to cut up the column in a regular way to reshape. I think if there was a 2D interpolation option that allowed one to replace the "missing" elements with a constant, that would work, but I can't find that. I would replace them with NaNs in that case.

답변 (1개)

Image Analyst
Image Analyst 2020년 1월 20일
Perhaps fillmissing()?
Or scatteredInterpolant()? (Dee attached demo.)
  댓글 수: 1
Daniel
Daniel 2020년 1월 20일
fillmissing needs an element there to replace essentially. I have missing elements, so I have to first have a way to say where to fill. scatteredInterpolant would work if you could "interpolate" by putting a constant value wherever interpolation was required. In my case, I would put NaNs there.

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

카테고리

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