Home > other >  Matlab with interp1 interpolation error, dear friends, please answer, thank you very much
Matlab with interp1 interpolation error, dear friends, please answer, thank you very much

Time:03-20

As the code below, the interpolation error: error using griddedInterpolant grid vector must contain the feature points, very desperate, someone answer using online sort sorting, but also useless, please Daniel to give directions, thank you very much!!!!!!
X=[1:0. 1:10, 7.11 8,11,9,11,11:0.1:20];
Y=x. ^ 3. * sin (x);
The plot (x, y); hold on;
[x, id]=sort (x);
Y=y (id);
Xx=(1-0. 001:20);
Xx, yy=interp1 (x, y, 'pchip');
The plot (xx, yy, 'r');

CodePudding user response:

Big brother, don't insert duplicate values, otherwise don't know what the point is to calculate, MATLAB initial assignment to the x with respect to OK

X=[1:0. 1:10, 7.11, 11:0. 1:20];

CodePudding user response:

Read the post time is many years ago, today I also met this problem, now find the reason: as the x axis, must be dull, not destroy the monotonicity of Numbers (including the number of repeat), hope to help to meet the same problem of confusion,
  • Related