Complete the code to interpolate the value at x = 2.5 using linear interpolation.
x = [1 2 3 4 5]; y = [10 20 30 40 50]; result = interp1(x, y, [1]);
The value 2.5 is between 2 and 3, so interp1 will interpolate at this point.
Complete the code to use 'nearest' method for interpolation at x = 3.7.
x = [1 2 3 4 5]; y = [10 20 30 40 50]; result = interp1(x, y, 3.7, [1]);
The 'nearest' method picks the nearest data point for interpolation.
Fix the error in the code to interpolate at x = 6 using extrapolation.
x = [1 2 3 4 5]; y = [10 20 30 40 50]; result = interp1(x, y, 6, 'linear', [1]);
To interpolate outside the range of x, use 'extrap' to allow extrapolation.
Fill both blanks to create a vector of interpolated values at points 1.5 and 4.5 using 'pchip' method.
x = [1 2 3 4 5]; y = [10 20 30 40 50]; xi = [[1] [2]]; result = interp1(x, y, xi, 'pchip');
The points 1.5 and 4.5 lie between the x values and are used for interpolation.
Fill all three blanks to interpolate values at points 2, 3.3, and 5 using 'spline' method.
x = [1 2 3 4 5]; y = [10 20 30 40 50]; xi = [[1] [2] [3]]; result = interp1(x, y, xi, 'spline');
The points 2, 3.3, and 5 are used for interpolation with the 'spline' method.