在 matlab 中插值不规则间隔的 3D 矩阵
我有一个温度曲线的时间序列,我想对其进行插值,我想问如果我的数据间隔不规则,该怎么做。
以下是矩阵的具体情况:
- 温度为 30x365
- 时间为 1x365
- 深度为 30x1
时间和深度都是不规则间隔的。我想问一下如何将它们插入到常规网格中?
我在 Matlab 中查看了 interp2
和 TriScatteredInterp
,但问题如下:
interp2
仅当数据位于常规网格中时才有效。TriscatteredInterp
仅当向量是列向量时才起作用。虽然时间和深度都是列向量,但温度不是。
谢谢。
I have a time series of temperature profiles that I want to interpolate, I want to ask how to do this if my data is irregularly spaced.
Here are the specifics of the matrix:
- The temperature is 30x365
- The time is 1x365
- Depth is 30x1
Both time and depth are irregularly spaced. I want to ask how I can interpolate them into a regular grid?
I have looked at interp2
and TriScatteredInterp
in Matlab, however the problem are the following:
interp2
works only if data is in a regular grid.TriscatteredInterp
works only if the vectors are column vectors. Although time and depth are both column vectors, temperature is not.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
函数
Interp2
根本不需要规则间隔的测量网格,它只需要单调网格。也就是说,存储在向量深度
和次
中的采样位置必须增加(或减少),仅此而已。假设这确实是情况*并且您想要在存储在向量
rdepths
和rtimes<中的常规位置**进行插值/code>,你可以这样做:
* :如果没有,您可以对行和列进行排序以返回单调网格。
**:事实上
Interp2
对输出网格没有限制(它可以是不规则的,甚至是非单调的)。Function
Interp2
does not require for a regularly spaced measurement grid at all, it only requires a monotonic one. That is, sampling positions stored in vectorsdepths
andtimes
must increase (or decrease) and that's all.Assuming this is indeed is the situation* and that you want to interpolate at regular positions** stored in vectors
rdepths
andrtimes
, you can do:* : If not, you can sort on rows and columns to come back to a monotonic grid.
**: In fact
Interp2
has no restriction for output grid (it can be irregular or even non-monotonic).我会使用您的数据来拟合样条曲线或多项式,然后定期重新采样。我强烈推荐 polyfitn 函数。事实上,约翰·德埃里科这个家伙的任何作品都令人难以置信。除此之外,当我有关于不规则间隔的 3D 问题的数据时,我过去曾使用过此函数,并且效果相当不错。如果你的数据集有很好的支持(我怀疑确实如此),那么这将是小菜一碟。享受!希望这有帮助!
I would use your data to fit to a spline or polynomial and then re-sample at regular intervals. I would highly recommend the polyfitn function. Actually, anything by this John D'Errico guy is incredible. Aside from that, I have used this function in the past when I had data on a irregularly spaced 3D problem and it worked reasonably well. If your data set has good support, which I suspect it does, this will be a piece of cake. Enjoy! Hope this helps!
尝试使用 MATLAB Central 上 John D'Errico 提供的 GridFit 工具。要使用它,请传入 2 个独立的数据向量(时间和温度)、相关数据矩阵(深度)以及规则间隔的 X 和温度。要使用的 Y 数据点。默认情况下,该工具还会对重叠(或接近)的数据点进行平滑处理。如果不需要,您可以通过各种配置选项覆盖此选项(和其他选项)。示例代码:
Try the GridFit tool on MATLAB central by John D'Errico. To use it, pass in your 2 independent data vectors (time & temperature), the dependent data matrix (depth) along with the regularly spaced X & Y data points to use. By default the tool also does smoothing for overlapping (or nearly) data points. If this is not desired, you can override this (and other options) through a wide range of configuration options. Example code: