I have calculated vector data, such that the data can be written and represented as , where each component is a function of all three coordinates; i.e. . I need to interpolate to be able to represent the inputs of a different vector anywhere, and have it be a vector output. This different vector is . Written out fully, you can see that each component of the vector M is an array which depends on all three x, y, and z coordinates. As a result, I can't simply use Interp3 three times. This means that I need the G's as a grid, so that I can query at points (Gx_q, Gy_q, Gz_q) and find their (x,y,z) inputs that give G.
Interp3 repeatedly gives errors of "Input is not a Meshgrid."
My vector data arrays (, , and ) are sized 31x31x31. I'm so lost; I've tried so many tricks that have failed. Any tricks? Will scatteredInterpolant() work?
The situation is analogous to this user's question (https://www.mathworks.com/matlabcentral/answers/408712-interpolating-scattered-3-dimensional-data), but distinctly different. The answers provided in () also are not quite related – something there is wrong, as well.
Previously, I've poorly or incorrectly explained my problem, and so those questions (and, as a result, answers) were phrased incorrectly. This is fixed.
To avoid confusion, I'll present the case where the M vector depends only on one coordinate, each, such that , which lets us write a scalar G as , and just do the process three times. The code would look like:
load('data.mat')x = 0:1000:30000;y = 0:1000:30000;z = 0:1000:30000;Gx_q = 721.0085; %These are example query points
Gy_q = 15.1313;Gz_q = 45.9302;Gx = x - squeeze(Mx(1,1,:))'; %These should be 1D arrays; for simplicity, in this case I would only need one column of each M_i array.
Gy = y - squeeze(My(1,1,:))';Gz = z - squeeze(Mz(1,1,:))';Gx_out = interp1(Gx,x,Gx_q,'linear','extrap');Gy_out = interp1(Gy,y,Gy_q,'linear','extrap');Gz_out = interp1(Gz,z,Gz_q,'linear','extrap');
Best Answer