フィルターのクリア

Using Interp1 - monotonic increasing values

1 回表示 (過去 30 日間)
maryam
maryam 2014 年 8 月 3 日
コメント済み: Image Analyst 2014 年 8 月 3 日
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!

採用された回答

Image Analyst
Image Analyst 2014 年 8 月 3 日
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 件のコメント
John D'Errico
John D'Errico 2014 年 8 月 3 日
編集済み: John D'Errico 2014 年 8 月 3 日
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
Image Analyst 2014 年 8 月 3 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by