How to interpolate/regrid 2-D array
显示 更早的评论
Hello,
I am trying to regrid data using a cubic interpolation. I have a 2-D matrix (var_in) with 2 coordinates (x_in and y_in), see the plot below:

I have created the two target 2-D coordinates (x_out and y_out), both with the same dimensions and monotonic. First, I tried using griddata, which I have used for other purposes and works well. However, in this case it did not produce the expected results, see the figure below. (I requested the limit up to 15000 in y_out).

You can notice the original data (var_in) varies from 0 to 1, while griddata produced a variable with very different limits.
Also, I tried using scatteredInterpolant by working around my data, but again it did not produce reasonable results:

As you can see, none of the two methods did not produce results similar to the original data. I tried to use interp2 and interpn but they did not work. I guess it is because x_in and y_in are not meshgrids.
Does anyone have a suggestion on how to solve this?
I am attaching a mat file that includes the original data, its coordinates and the requested output coordinates: x_in, y_in, var_in, x_out, y_out.
Thanks.
3 个评论
Image Analyst
2020-3-21
You forgot to attach your .mat file.
In the meantime, you can check out my attached scatteredInterpolant demo.
Gonzalo Ferrada
2020-3-23
Image Analyst
2020-3-24
编辑:Image Analyst
2020-3-24
Why is x_in a 2-D matrix? I thought it was just a 1-D list of x coordinates, and you had a matching/corresponding list of y values, then you had some data value for each (x,y) pair. Please explain what this all represents:
struct with fields:
var_in: [52×44 single]
x_in: [52×44 double]
x_out: [289×775 double]
y_in: [52×44 single]
y_out: [289×775 single]
Did you already run x and y through meshgrid() to get x_in and y_in? If so, do you have the original x and y. I guess I could get it using unique() if I had to.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




