MATLAB: 3d data fitting from three 1D vector

3d3d plotscftoolcurve fittinginterpolationMATLABpolyfitnregressionsurface

I want to obtained fitting function Delta_n = f(width,gap, thick). I have run the EM simulation of particular device and obtained the value of Delta_n by varying width, gap and thickness. There is no mathematical model that I can use to fit. The data directily came from EM simulations. I have attached the data in case you want to look into it. The data contain three vectors width_j (1×11), gap_i (1×11) and thick_k (1×10), I have stored the value of Delta_n (11 x 11 x 10) using three nested loop as shown below.
delta_n = matrix (length(gap_i),length(width_j),length(thick_k));
for (kk=1:length(thick_k))
for (ii=1:length(gap_i))
delta_n(ii,jj,kk) = EM Simulation (width_i(jj), gap_j(ii), thick_k(kk)) % I have used third party EM simulator here.
I have gone through several MATLAB answer mostly recommends to use scatteredInterpolant or polyfitn. But here I think is the problem data arrangement. Can anyone please help to obtained the fitting function delta_n=f(width,gap,thick)? I can't use cftool interactive app as it only supports only 2D fucntions.

Best Answer

You first need to create a grid from the three input variables and then apply scatteredInterpolant
[W, G, T] = ndgrid(width_j, gap_i, thick_k);
Model = scatteredInterpolant(W(:), G(:), T(:), delta_n(:))