interpol Function

public elemental function interpol(x1, x2, y1, y2, x_obj) result(y)

Linear interpolation.

Calculates the linear interpolation between two points at a desired x value with the equation:

Since this function is defined as elemental it will also interpolate a set of vectors.

Examples of usage:

x1 = 2
x2 = 5
y1 = 2
y2 = 9
y = interpol(x1, x2, y1, y2, 2.3)
x1 = 2
x2 = 5
y1 = [2, 6]
y2 = [9, 15]
y = interpol(x1, x2, y1, y2, 2.3)

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: x1

First point x value

real(kind=pr), intent(in) :: x2

Second point x value

real(kind=pr), intent(in) :: y1

First point y value

real(kind=pr), intent(in) :: y2

Second point y value

real(kind=pr), intent(in) :: x_obj

Desired x value to interpolate

Return Value real(kind=pr)

y value at x_obj