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
-
Remove all the words that end with "ain"
2402 Solvers
-
Getting the indices from a matrix
656 Solvers
-
Relative ratio of "1" in binary number
1455 Solvers
-
1485 Solvers
-
the average value of the elements
1768 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!