Problem 72. Interpolator
Solution Stats
Problem Comments

9 Comments
WTF!
I know the function interp!! but I thougth I must program it... :(
That's true, the instructions here do indicate that you're supposed to program it from scratch (e.g. find a(n) & a(n+1)).
For convenience, it would be useful if the code input variables were related to the variables listed in the solution window. We are given a, b, alpha, and beta in the Test Suite; the function that we are to type involves vb, va, a, and b. Sure, we can update it, but it just seems careless.
This is my first solving problem
First find the position then finding the gap length between arrays.
enjoyed this problem!
I really do not understand the text in the Problem. And, here is why:
If va = a(n) (is some arbitrary value picked between a(1) and a(end), and n can be any elementindex number related to vector a), then the values that "flank it" (as said in Problem's text, by both sides of the vector a) should be a(n1) and a(n+1), and not a(n) and a(n+1) as mentioned in the Problem's text. Correspondingly, in vector b, the newly determined value should be between (interpolated): b(n1), and b(n+1), and not as said in Problem's text b(n) and b(n+1). Am i right, or, I am missing something?
P.S. If, I am right  on upper mentioned, please, pay more attention on posing the Problems text! If, I am not right, I do apologize, but, I kindly ask for clear (!) explanation.
The tests do not check va equal to a(1) or a(n).
Test cases added to include for corner values as well.
Solution Comments

1 Comment
the question language must be improved  flank it and all is absurd, i think

1 Comment
The wording on this was a little off, I had to review results to see what the aim was. But not difficult. Thanks for the challenge.

1 Comment
good job!

1 Comment
tricky

1 Comment
kind of pointless, since the function already exists

2 Comments
u cannot use 'mean',if not use 3.5,for instance 3.2 3.3
u should use interp1
my answer https://blog.csdn.net/qq_44846756/article/details/116567963
@arsenic, your comment on the main post is deleted because it revealed the answer. It is not the best practice to do so.

1 Comment
I couldn't remember interp1 but I formed a very silly code to do the same

1 Comment
hi Giorgio, can you provide an explanation for this? it seems really hard for me

1 Comment
Absolutely for the tests...

3 Comments
For convenience, it would be useful if the code input variables were related to the variables listed in the solution window. We are given a, b, alpha, and beta in the Test Suite; the function that we are to type involves vb, va, a, and b. Sure, we can update it, but it just seems careless.
good
good

1 Comment
this won't work when the point is not in middle of 2 elements, for example a=3.3 in test 1
Problem Recent Solvers3041
Suggested Problems

22158 Solvers

Getting the indices from a matrix
482 Solvers

520 Solvers

399 Solvers

2745 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!