problem with interp1

1 次查看(过去 30 天)
Stetson Spencer
Stetson Spencer 2018-11-27
回答: Bruno Luong 2018-11-27
Hi, for some reason when I try to use the interp1 function it gives me an error "Error using griddedInterpolant. The grid vectors must contain unique points."
but in my code I already accounted for that by doing the following:
dnew = unique([dlrg dmed dsml]);
plrg = interp1(log10(dlrg),plrg,log10(dnew),'linear','extrap');
why is it ignoring the fact that I told it to use unique points?
  1 个评论
Adam Danz
Adam Danz 2018-11-27
Perhaps your variables log10(dlrg),plrg do not have unique coordinates?

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2018-11-27
It is dlrg that must contain unique points. There is no requirement for uniquness on dnew.

更多回答(2 个)

Stephen
Stephen 2018-11-27
Your definition of "dlrg" probably contains duplications. You aren't running unique on "dlrg" and that is the vector of values you are interpolating on. Also, you're assigning the variable name "plrg" to both the "Y" input and "yi" output of the function. That rarely ends well for me.

Bruno Luong
Bruno Luong 2018-11-27
[x,i] = unique(log10(dlrg))
plrg = interp1(x,plrg(i),log10(dnew),'linear','extrap');

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by