How to fix error about interp1?

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);

回答(1 个)

KSSV
KSSV 2021-3-31
编辑:KSSV 2021-3-31
x = b(:,1) ;
y = b(:,2) ;
xi = linspace(min(x),max(x),4095)' ;
ai_b = interp1(x,y,xi);

4 个评论

Thanks for the response.
It is showing an error as ' the input must be scalar for linspace '
Actually I have used same code for another material as well but for both I have loaded different mat files and then wrote the above stated code accordingly.
But it is showing error as:
Error using griddedInterpolant. The grid vectors must contain unique points.
Type error..edited the code......If it works fine else attach your data.
Without data how to run?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

评论:

2021-3-31

Community Treasure Hunt

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

Start Hunting!

Translated by