Watch this Author's files
Excellent. Exactly what I was looking for!
Simple and intuitive. This was definitely missing in matlab!
Following improvements could be made:
1. Handle start and end of range in case where it is not exactly on a sample point
2. Check that x is monotonically increasing and resort vectors if necessary.
There is a BUG in the calculation of the index of the upper bound. You must call the min() function to find the correct index, not the max() function.
This is a nice short code, but it covers only a very special case and does not tell which one exactly.
I recommend spincalc() from Jonathan Fuller. It is much more powerfull!