フィルターのクリア

Error using interp1

2 ビュー (過去 30 日間)
David E.S.
David E.S. 2021 年 2 月 26 日
コメント済み: David E.S. 2021 年 2 月 26 日
Hi,
I want to run the following code in order to interpolate missing values of latitudes and longitudes between two dates.
% location of the known latitudes and longitudes
indKnownLATITUDE = ~isnan(arch.latitude);
indKnownLONGITUDE = ~isnan(arch.longitude);
% interpolate to obtain values of unknown values
arch.latitude(~indKnownLATITUDE) = interp1(arch.FECHATXT(indKnownLATITUDE),arch.latitude(indKnownLATITUDE),arch.FECHATXT(~indKnownLATITUDE)) ;
arch.longitude(~indKnownLONGITUDE) = interp1(arch.FECHATXT(indKnownLONGITUDE),arch.longitude(indKnownLONGITUDE),arch.FECHATXT(~indKnownLONGITUDE)) ;
The error is:
Error using griddedInterpolant
The grid vectors must contain unique points.
F = griddedInterpolant(X,V,method);
I know I have to use the unique( ) function, so I've tried to introduce it in the code given above but it still gives me errors. Can you help me?
Thanks!
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 26 日
Is your original data truly scattered with unique latitude and longitude, or is it really grid based?
If you have two locations with the same latitude and different latitude, are you expecting they would have the same value?
David E.S.
David E.S. 2021 年 2 月 26 日
編集済み: David E.S. 2021 年 2 月 26 日
This is an example of my data:
Although the same date value is always shown, the decimal places are different. Latitudes and longitudes can be repeated and they're not sorted.
If you have two locations with the same latitude and different latitude, are you expecting they would have the same value?
No. For example a point can be (28.47, -17.21) and another (28.47, -16.14).

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 26 日
Convert the Date + Time into datetimes . Use those as the independent variable and lat as the dependent variable. Remove the entries corresponding to unknown lat/long, then interp1() on what remains at the times the missing records appear.
I was going to suggest that you use spline interpolation, but as the times are a few minutes apart, it is no longer clear to me that smooth interpolation is warranted. It depends what is being tracked. Looks like vehicle location, in which case motion could probably not be assumed to be smooth.
  1 件のコメント
David E.S.
David E.S. 2021 年 2 月 26 日
I'll try it, thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by