problem with interp1

1 Ansicht (letzte 30 Tage)
Stetson Spencer
Stetson Spencer am 27 Nov. 2018
Beantwortet: Bruno Luong am 27 Nov. 2018
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 Kommentar
Adam Danz
Adam Danz am 27 Nov. 2018
Perhaps your variables log10(dlrg),plrg do not have unique coordinates?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (2)

Stephen
Stephen am 27 Nov. 2018
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 am 27 Nov. 2018
[x,i] = unique(log10(dlrg))
plrg = interp1(x,plrg(i),log10(dnew),'linear','extrap');

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by