Table Of Contents

interpolate1d

Version:
    Last Modified: March 15, 2017

    Interpolates y-values based on sample data using a specified method.

    Syntax

    y2 = interpolate1d(y1, x2)
    y2 = interpolate1d(x1, y1, x2)
    y2 = interpolate1d(x1, y1, x2, method)
    Legacy name: interp1

    Inputs

    y1

    Sample y-values. If y1 is a matrix, MathScript performs interpolation for each column in the matrix. If y1 is complex, MathScript performs interpolation for the real part and the imaginary part, respectively. y1 is a real or complex vector or matrix.

    x2

    X-values at which you want to interpolate y-values. x2 is a real vector.

    x1

    Sample x-values. If you do not specify x1, MathScript sets x1 to the values of 0 ... length( y1 ) - 1. x1 is a real vector.

    method

    Interpolation method to use. method is a string that accepts the following values:

    Name Description
    'cubic'

    Performs cubic Hermite interpolation.

    'linear'

    Performs linear interpolation.

    'nearest'

    Chooses the y1 value corresponding to the x1 value that is nearest to the current x2 value. MathScript sets the interpolated value to the nearest data point.

    'spline'

    Performs spline interpolation.

    Default: 'linear'

    Outputs

    y2

    Y-values interpolated at the values of x2. y2 is a real or complex vector or matrix.

    X1 = -4:0.5:4;
    Y1 = 1.02*X1.^3+0.5*X1.^2+2;
    X2 = -4:0.1:4;
    Y2 = interpolate1d(X1, Y1, X2, 'spline')

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics