

$$\frac$$Īs can be seen in W\$\alpha \$ of the first and W\$\alpha \$ of the second (as the alternate forms are neatly in the same location, you can toggle between both tabs)Įven without the additional brackets around ((x - x0) / (x1 - x0)), it would still be the same thing. If (detail_sensativity >= min & detail_sensativity = alpha & detail_sensativity = alpha.end)ĭouble res = y0 + ((x - x0) / (x1 - x0)) * (y1 - y0) Std::vector::const_iterator it = std::find(alpha.begin(), alpha.end(), detail_sensativity) Įlse // we need linear interpolation/extrapolation.ĭouble max = *std::max_element(alpha.begin(), alpha.end()) ĭouble min = *std::min_element(alpha.begin(), alpha.end()) in case the interoplation point alraedy exists in the array double Model::Interp1(const std::vector& alpha, const std::vector& varSurf, double detail_sensativity) Please review the extrapolation part as I'm not quite sure about it and comment about the algorithm correctness. It also seems that the original MatLab program that I am converting should have used linear interpolation, so the question is probably moot.GriddedInterpolant(X,V,method) is doing inside Interp1.

(2048 data points)Īny thoughts as to how I can get results that are consistent with MatLab?Įdit: I understand that there is some latitude in implementation for cubic interpolation algorithms which probably accounts for the differences I'm seeing.

In MatLab the usage is slightly different: yi = interp1(x,Y,xi,'cubic')įor a trivial example the results are the same:

I'm converting a MatLab program to Python, and I'm having problems understanding why 1d is giving different results than MatLab interp1.
