What would be the out of Interp1?

  • Thread starter Thread starter vivek91m
  • Start date Start date
AI Thread Summary
The command y = interp([1:5 4:9], 1:11, 4) results in an error because the function 'interp' is undefined in GNU Octave. In contrast, using y = interp1([1:5 4:9], 1:11, 4) yields a value of 6, which is the last value calculated for x. The discussion highlights that interp1 requires the input vector X to be strictly monotonic, meaning it must contain distinct values. The example illustrates that the input vectors in the command do not meet this requirement, leading to potential confusion about the interpolation function's behavior. Understanding these constraints is crucial for proper usage of interpolation functions in Octave.
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?
 

Similar threads

Replies
4
Views
3K
Replies
1
Views
2K
Replies
4
Views
1K
Replies
1
Views
2K
Replies
8
Views
609
Replies
2
Views
2K
Replies
0
Views
2K
Back
Top