# What would be the out of Interp1?

1. Jul 23, 2012

### vivek91m

Hello guys,

If i run the following command

y = interp([1:5 4:9], 1:11, 4);

what would be the output of the same, and what does it mean?

2. Jul 24, 2012

### Simon Bridge

Code (Text):
> y = interp([1:5 4:9], 1:11, 4)
error: `interp' undefined near line 92 column 5
error: evaluating assignment expression near line 92, column 3
... does not exist in gnu octave. How about interp1()?
Code (Text):
> y = interp1([1:5 4:9], 1:11, 4)
y =  6
... which would be the last value calculated for x.
Put Y=11:-1:1 and it gives you

Find out what it means from the help file:
Code (Text):
> help interp1
-- Function File: YI = interp1 (X, Y, XI)
One-dimensional interpolation. Interpolate Y, defined at the
points X, at the points XI. The sample points X must be strictly
monotonic. If Y is an array, treat the columns of Y separately.
... or hunt down the function m-file.
... or just plot Y vs X and see where XI,YI compare.

Presumably you mean - "how does the interpolation function handle the case where the input vectors do not represent a function?"

3. Aug 15, 2012

### vivek91m

As mentioned in the help:

"The sample points X must be strictly monotonic."

interp1([1:5 4:9], 1:11, 4)

should give an error because x ([1:5 4:9]) is not strictly monotonic here, it doesn't have distinct values. Isn't it?