MATLAB Answers

How to fix error about interp1?

3 views (last 30 days)
Shital Inmulwar
Shital Inmulwar on 31 Mar 2021
Commented: KSSV on 31 Mar 2021
I am getting this errors:
Error using griddedInterpolant. The grid vectors must contain unique points.
Error in interp1 (line 161)
F =griddedInterpolant(X,V,method)
Error in interpolation_diff (line 184)
ai_b = interp1(b(:,1), b(:,2),0:4095);
My code line is:
[r,c] = size(b);
ai_b = interp1(b(:,1), b(:,2),0:4095);

Answers (2)

KSSV
KSSV on 31 Mar 2021
Edited: KSSV on 31 Mar 2021
x = b(:,1) ;
y = b(:,2) ;
xi = linspace(min(x),max(x),4095)' ;
ai_b = interp1(x,y,xi);
  4 Comments
KSSV
KSSV on 31 Mar 2021
Without data how to run?

Sign in to comment.


VBBV
VBBV on 31 Mar 2021
Check the
b(:,1);
b(:,2);
vectors in command window,
the values must either be in increasing order or decreasing order
  1 Comment
VBBV
VBBV on 31 Mar 2021
F =griddedInterpolant(X,V,method)
Specify the method for the function

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!

Translated by