Interpolation for 1-D, 2-D, 3-D, and N-D gridded data in functionformat

I have an N-D gridded data and I want to fit a hyperplane on them. There are two almost similar commends in Matlab but none of them is the one I'm looking for. The following function is almost the one I'm looking for but it works just for 2D (line) and 3D (surface); however, I'm looking for N-Dimension https://www.mathworks.com/help/curvefit/fit.html Another command might be useful but still is not the exact one I'm looking for is interpn. Although it works for N-D, it is not gerenate a black box or fucntion as the way you can input value and have the output. https://www.mathworks.com/help/matlab/ref/interpn.html
In this regard and all the explanations above, do you know how I can address this issue? Thanks

답변 (2개)

Stephen23
Stephen23 2018년 1월 3일
편집: Stephen23 2018년 1월 3일
ND curve-fitting is not really a trivial task. You can easily define a "black box or fucntion as the way you can input value and have the output" by defining an anonymous function which contains interpn, e.g.:
>> [X1,X2] = ndgrid((-5:1:5));
>> R = sqrt(X1.^2 + X2.^2)+ eps;
>> V = sin(R)./(R);
>> fun = @(q1,q2)interpn(X1,X2,V,q1,q2,'cubic');
>> fun([1,2;3,4],[0,0;1,1])
ans =
0.84147 0.45465
-0.0065407 -0.20163
Matt J
Matt J 2018년 1월 3일
편집: Matt J 2018년 1월 3일
Your question isn't terribly clear. Fitting and interpolation are two very different things. I suspect what you might be looking for is lsqcurvefit(). It will let you fit parameters to an N-dimensional black-box function. However, hyperplanes are especially simple functions. If you are merely trying to fit an N-dimensional hyperplane given M data points organized into an MxN array A, it can be done by very simple linear algebra:
d=mean(A,1);
[~,~,V]=svd(A-d,0);
hyperplaneNormal=V(:,end);
hyperplaneShift=d*hyperplaneNormal;

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

질문:

2018년 1월 2일

편집:

2018년 1월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by