Interpolation outside the domain - meshgrid and griddata
Show older comments
Hello Matlab community,
I need your knowledge on a problem.
I have three vectors, two of them being (x,y) pairs, and the third being T=f(x,y).
I used meshgrid in the following way:
x_grid = linspace(min(x),max(x),1000);
y_grid = linspace(min(y),max(y),1000);
[xq,yq]=meshgrid(x_grid , y_grid );
Now I can plot my data in the following way:
T_interp = griddata(X,Y,T,xq,yq);
figure
contour(xq,yq,T_interp )
I attach an image with the cotour plot, and the domain I need superimposed (grey circles).
As seen in the image, I get an interpolation outside the boundaries of the domain I need.
Is there a way to avoid that?
Many thanks and best regards.
2 Comments
Maria Angela Agizza
on 15 May 2018
Edited: Walter Roberson
on 15 May 2018
KSSV
on 16 May 2018
Yes it is very much possible to extract the boundary of the given domain. And using inpolygon is apt. Note that, you have used a loop for that, which in unnecessary and time consuming. Attach your data, so that we can help you further. Mean while, you can have a look on boundary to extract the boundaries of the grid.
Answers (0)
Categories
Find more on Downloads in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!