フィルターのクリア

Calculations between successive points in an array?

1 回表示 (過去 30 日間)
Stanley Kubrick
Stanley Kubrick 2015 年 2 月 9 日
コメント済み: Stanley Kubrick 2015 年 2 月 9 日
My script analyzes sensor data collected from a mobile device. In my case, I'd like to use the GPS to find the average distance between successive lat/long points in my input array. The distance calculation is simple, but I'm hung up on how to set up a loop to find the distance between successive points. Let's use the following arrays as an example:
Lat = [38.896368, 38.8963633, 38.896356, 38.8963606, 38.896357]
Long = [-77.0366636, -77.0362163, -77.035574, -77.0347948, -77.033968]

採用された回答

Image Analyst
Image Analyst 2015 年 2 月 9 日
Try this:
distances = zeros(1, length(Lat));
for k = 2 : length(Lat)
% Get distances using current point, and prior point.
distances(k) = CalculateDistance(Lat(k), Long(k), Lat(k-1), Long(k-1));
end
CalculateDistance() is your function that you said you knew how to do.
  1 件のコメント
Stanley Kubrick
Stanley Kubrick 2015 年 2 月 9 日
Awesome, this works perfectly thanks a lot.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by