Background:
- I am trying to project scattered 2D raw data (rawX, rawY, rawZ) onto a 2D grid (intX, intY) using GRIDDATA()
- The scattered 2D raw data has a data gap where no measurements have been made (rawZ = 0), as shown in the figure
- When I use GRIDDATA(), the data gap gets automatically filled in by the interpolation operation (see figure), but I want the data gap to exist in the interpolated data as well
- intX, intY are created using MESHGRID()
Tried Methods
- Setting rawX and/or rawY = NaN, but this does not help
- I do ignore the gapped data points (rawZ == 0) doing the interpolation as the zero values will locally distort the interpolated values
Question
- Is there method to directly have GRIDDATA() ignore the rawZ data gap when creating intZ?
Much appreciated!!
I have attached the code below:
% Remove data gaps for interpolation
mask = (rawZ==0);rawX_adj = rawX(~mask);rawY_adj = raw(~mask);rawZ_adj = raw(~mask);% Create the interpolation mesh grid (intX, intY)
intX = linspace(min(rawX_adj(:)), max(rawX_adj(:)), 100);intY = linspace(min(rawY_adj(:)), max(rawY_adj(:)), 100);[intX, intY] = meshgrid(intX, intY);% Project the raw data onto the (intX, intY) grid
intZ = nangriddata(rawX_adj, rawY_adj, rawZ_adj, intX, intY);
Best Answer