You are here

Example 5.2

9 October, 2015 - 15:37

The table we created above has only 6 elements in it and suppose we need a more detailed table. In order to do that, instead of a single new x value, we can define an array of new x values, the interp1 function returns an array of new y values:

new_x = 0:0.2:5;
new_y = interp1(x,y,new_x);

Let’s display this table

[new_x',new_y']

The result is

ans =
 
         0          0
    0.2000     4.0000
    0.4000     8.0000
    0.6000    12.0000
    0.8000    16.0000
    1.0000    20.0000
    1.2000    28.0000
    1.4000    36.0000
    1.6000    44.0000
    1.8000    52.0000
    2.0000    60.0000
    2.2000    61.6000
    2.4000    63.2000
    2.6000    64.8000
    2.8000    66.4000
    3.0000    68.0000
    3.2000    69.8000
    3.4000    71.6000
    3.6000    73.4000
    3.8000    75.2000
    4.0000    77.0000
    4.2000    83.6000
    4.4000    90.2000
    4.6000    96.8000
    4.8000   103.4000
    5.0000   110.0000