You are here

Example 5.1

9 October, 2015 - 15:37

To demonstrate how the interp1 function works, let us create an x-y table with the following commands;

x = 0:5;
y = [0,20,60,68,77,110];

To tabulate the output, we can use

[x',y']

The result is

ans =
    0   0 
    1  20
    2  60
    3  68
    4  77
    5 110

Suppose we want to find the corresponding value for 1.5 or interpolate for 1.5. Using y new = interp1(x,Y,x new) syntax, let us type in:

y_new=interp1(x,y,1.5)
y_new =
    40