What would be the out of Interp1?

  • Thread starter Thread starter vivek91m
  • Start date Start date
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
2 replies · 2K views
vivek91m
Messages
8
Reaction score
0
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?
 
Physics news on Phys.org
Code:
> 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:
> 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:
> 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?"
 
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?