Problem 55970. Interpolated Value Between Two Points

Given two points, and , a new location x, and a method "linear" or "cubic", return the value of a linear or cubic interpolant through the two points at the new location x, using the formulas below.
Linear:
Cubic:
where and .
(This formulation for the cubic interpolant has zero derivative at each interpolation point.)
If , your function should produce an error with the message "x2 must be greater than x1".
If , your function should produce a warning with the message "x is outside the interval [x1,x2]" (but still return the value of the interpolant).
If the method is given as anything other than "linear" or "cubic", your function should produce an error with the message "method must be either "linear" or "cubic"".

Solution Stats

29.19% Correct | 70.81% Incorrect
Last Solution submitted on Aug 28, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers77

Suggested Problems

More from this Author12

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!