Something like reshape but accounting for missing values

3 vues (au cours des 30 derniers jours)
Daniel
Daniel le 20 Jan 2020
Commenté : Daniel le 20 Jan 2020
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.

Réponses (1)

Image Analyst
Image Analyst le 20 Jan 2020
Perhaps fillmissing()?
Or scatteredInterpolant()? (Dee attached demo.)
  1 commentaire
Daniel
Daniel le 20 Jan 2020
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur NaNs dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by