evaluate the interpolant+correcting script+equation from interpolated data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
i am trying to evaluate interpolant by this code,would somebody plz help me to correct that??
clear
clc;
BHv= [1:1:8];
phiv= [0:10:30];
h = [ 1 1.02 1.11 1.21 1.3 1.4 1.59 1.78; ...
1 1.11 1.35 1.62 1.95 2.33 3.34 4.77; ...
1.01 1.39 2.12 3.29 5.17 8.29 22 61; ...
1.13 2.5 6.36 17.5 50 150 1400 14800];
mesh(BHv,phiv,h)
[phim BHm] = meshgrid(phiv,BHv);
hh=interp2(BHv,phiv,h,phim,BHm,'spline');
mesh(phim,BHm,hh);
hold on
[fm,Bm] = meshgrid(phiv,BHv);
plot3(fm,Bm,h+.1,'0');
hold off
xlabel('x-axis,(B/H)')
ylabel('y-axis,phi')
zlabel('depth factor,hc')
title('depth factor(hc) measurements,mandel & salencon 1969')
and is there any way get the equation and coefficients of the interpolated data????
0 Kommentare
Antworten (2)
John D'Errico
am 24 Jul. 2011
Interp2 is a spline. There is no simple set of "coefficients" you can extract and use or look at. At best, you can extract a set of coefficients for each small piece of the result. In this case, there will be dozens of such sets of coefficients. It would be far less illuminating than just looking at the original data points, and those coefficients will probably take more space to write down.
As far as getting the "equation", this is perhaps the most common question asked about tools like this, and the answer is always - don't bother.
If you really need an equation, then you must pose a mathematical form for that surface. YOU must do this first. Given a mathematical form, a model, you can then use tools to estimate the coefficients of the model. Look at the curve fitting toolbox, or many other tools. But not interp2. Interp2 will give you only an interpolant, a reasonably good one in general, but nothing more.
2 Kommentare
the cyclist
am 24 Jul. 2011
I don't think there is a function that will output this info. I think you will have to use "edit interp2", which will lead you into "edit spline", to get into the guts of the calculation. I see that inside the spline() function (line 66 of R2011a) there is the comment "the interpolant is a parabola", that is probably getting the coefficients you need.
I realize that this is not a very satisfying answer, so I hope someone has a better one for you!
2 Kommentare
the cyclist
am 24 Jul. 2011
Milad: Please read John's answer before digging into the code I mention!
John: I totally agree with the points you made in your answer, about the almost-always-useless nature of extracting the coefficients of each piecewise polynomial. (I had assumed that Milad knew he would be getting a gazillion coefficients, but now I think he might believe it is one over-arching equation.)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!