'Grid Vectors not strictly monotonic increasing'
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rebecca
le 11 Mai 2016
Réponse apportée : umesh sahu
le 14 Mar 2019
Hi,
I am trying to interpolate 3 datasets using interp1...but am getting the error 'Grid Vectors not strictly monotonic increasing' - which I do not understand.
My datasets are given in the attachement. I want to interpolate each to find at what value of A each of C11, C12 and C44 equal a known reference values - C11ref, C12ref, C44ref. I have used the following.
C11A = interp1(C11, A, C11ref);
C12A = interp1(C12, A, C12ref);
C44A = interp1(C44, A, C44ref);
The first of these works fine. The error is thrown for the second and third...
If anybody could shed some light, I would be grateful.
0 commentaires
Réponse acceptée
Jos (10584)
le 11 Mai 2016
Modifié(e) : Jos (10584)
le 11 Mai 2016
This happens when values in X are not unique
X = [1 2 3 3 4 5]
Y = [10 20 28 32 40 50]
interp1(X,Y, 3.5)
A workaround is to accumulate Y over all unique values of X
X = [1 2 3 3 4 5]
Y = [10 20 28 32 40 50]
[X2, ~, jx] = unique(X)
Y2 = accumarray(jx, Y ,[], @mean)
R = interp1(X2,Y2, 3.5)
2 commentaires
Jos (10584)
le 11 Mai 2016
My sentence was incorrect. I have edited it.
interp1 sorts the X values, and then the Y values accordingly
X = [1 2 3 4 5] ; Y = [10 20 30 40 50] ;
ri = randperm(5)
interp1(X(ri),Y(ri),2.5) %→ 25, always
Plus de réponses (1)
umesh sahu
le 14 Mar 2019
what if i want to delete all the values for X=3 and carry out the interpolation with rest X values ,how the "accumarray" command will have to change?
0 commentaires
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!