Something like reshape but accounting for missing values
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!