MATLAB: Unstructured grid to structured grid

interp2 structured unstructured

Dear all, what would be the best way, in your opinion, to get a structured grid out of an unstructured grid?
What I have is something like this:
x y f
1 12 7
3 10 4
1 11 2
2.4 15 0
So basically x and y are totally random and in no specific order. What I need is to resample the values of f on a structured grid with a constant step.
I had a quick look at interp2 and it looks like it will only work if my vectors are strictly monotonic which is not the case as I have plenty of repeated values for x and y.
Thanks a lot

Best Answer

scatteredInterpolant may do what you need. Like this:
x = [1 3 1 2.4].';
y = [12 10 11 15].';
f = [7 4 2 0].';
si = scatteredInterpolant(x, y, f); % using default linear interpolation
xint = (0.5:0.5:3.5).'; % regular grid
yint = (9.5:0.5:15.5).';
fint = si({xint yint})