Problem 72. Interpolator
You have a two vectors, a and b. They are monotonic and the same length. Given a value, va, where va is between a(1) and a(end), find the a(n) and a(n+1) that flank it. Now interpolate the value, vb, such that it is proportionally between b(n) and b(n+1).
Note that va can land exactly on a value of a as well.
Solution Stats
Problem Comments
-
9 Comments
Show
6 older comments
Peter Orthmann
on 3 Oct 2022
The tests do not check va equal to a(1) or a(n).
Dyuman Joshi
on 4 Oct 2022
Test cases added to include for corner values as well.
Cláudio Márcio
on 7 Apr 2024
The test is broken. The question statements gives that "va" is between a(1) and a(end), but the last test gave va = a(1).
Solution Comments
Show commentsProblem Recent Solvers3381
Suggested Problems
-
5975 Solvers
-
Back to basics 21 - Matrix replicating
1628 Solvers
-
Sum of first n terms of a harmonic progression
442 Solvers
-
1217 Solvers
-
the average value of the elements
1767 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!