interpolate metodu
Açıklaması şöyle.
Açıklaması şöyle.
The trick here is that you need two arrays to create a spline but you only have one. Thus you need to fabricate an array. You can assume that the input array contains your y values and that the new fabricated array contains your x values so for any given x you have a corresponding y.Şöyle yaparız.
// To expand the array
public static double[] expand(double[] yarray, int newSize) {
final int length = array.length;
// let's calculate the new step size
double step = (length * 1.0) / newSize;
// fabricated array of x values
for(int i = 0; i < length; ++i) {
x[i] = i;
}
// using Linear interpolator but it can be any other interpolator
LinearInterpolator li = new LinearInterpolator(); // or other interpolator
PolynomialSplineFunction psf = li.interpolate(x, yarray);
double[] expandedArray = new double[newSize];
double position = x[0];
for (int i = 0; i < newSize; ++i) {
expandedArray[i] = psf.value(position);
position += step;
}
return expandedArray ;
}
Hiç yorum yok:
Yorum Gönder