'Grid Vectors not strictly monotonic increasing'

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.

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

2 Comments

This happens when values in X are not unique. No, this happens when the values is X are not strictly monotonic increasing as per the error message. If
X = [1 3 5 4 2]
between which indices of X should the interpolation of 2.5 occur?
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

Sign in to comment.

More Answers (1)

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?

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

on 11 May 2016

Answered:

on 14 Mar 2019

Community Treasure Hunt

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

Start Hunting!