# How to find interpolated values when there are multiple?

47 views (last 30 days)
Adam Hockley on 9 May 2018
Commented: Sahil WANI on 15 Aug 2022
I'm looking to find points where a vector crosses a certain threshold. I have been using interp1 to try to accomplish this but it does not recognise multiple solutions.
for example:
a = [1 2 3 5 8 4];
b = interp1(a, 1:length(a), 6);
returns 4.3333
This is one of the correct answers, but I am looking to get this to return both points where the interpolated value would be 6 (4.33 and 5.5). Any help much appreciated!
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

John D'Errico on 9 May 2018
Edited: John D'Errico on 9 May 2018
interp1 assumes a single valued functional relationship. You cannot use interp1 to do what you wish to do.
Instead, use a tool like Doug Schwarz's intersections , downloaded from the file exchange.
a = [1 2 3 5 8 4];
intersections(1:length(a),a,[1 6],[6 6])
ans =
4.3333
5.5
##### 4 CommentsShowHide 3 older comments
Sahil WANI on 15 Aug 2022
Thanks @Walter Roberson! Very useful.

Sign in to comment.

### Categories

Find more on Interpolation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!