Using Interp1 - monotonic increasing values
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
maryam
am 3 Aug. 2014
Kommentiert: Image Analyst
am 3 Aug. 2014
Hi, I have a data set consisting some dates and value. I would like to use interp1 so that I will be able to expand the values so that the value matrix include some more values corresponding to some more dates in the range of the dates that I already have but I get this error! "The grid vectors are not strictly monotonic increasing." I have attached the command line and the required matrices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fd = interp1(diff_dates,diff_flows,res2(:,1),'linear');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Have tried everything I can think of and find on the net but no luck
Thanks loads!
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 3 Aug. 2014
You have some values of diff_dates and res2 that are exact repeats. So when there are 2 y values for a single x value, what's it supposed to do? It doesn't know so it throws an error. Make sure you validate your input arrays or else it's "garbage in, errors out".
5 Kommentare
John D'Errico
am 3 Aug. 2014
Bearbeitet: John D'Errico
am 3 Aug. 2014
But you have a function that has TWO y values at the same x. What value should your function have in that vicinity?
For example,
x = [0 1 1 2];
y = [1 2 3 4];
Now, I'd like to interpolate at a new value of x, say x = 0.5.
Suppose I arbitrarily adjust those x values to
x = [0 1 1.000000001 2]
Now I can interpolate at x = 0.5, since the function is single valued.
But be careful that you did not adjust the first of those duplicated values, since we would get a different interpolated prediction from the sequence below:
x = [0 1.000000001 1 2]
The point is, the common approach that is unambiguous is to average the y over any duplicates in x, replacing those duplicates with a new sequence
x = [1 1 2];
y = [1 2.5 4];
Image Analyst
am 3 Aug. 2014
Good point. I was thinking more like a regression than an interpolation. If you nudged one of the points over and wanted some point in the "in between" area on the right, then it would matter which of the two points got nudged over closest to that point. Maybe for duplicated points she should just replace those two (or multiple) points with one x value and the average of the multiple y values.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!