MATLAB: ‘Grid Vectors not strictly monotonic increasing’

interpolation

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.

Best Answer

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)