Performing calculation across large data set
古いコメントを表示
I have a large matrix of latitude and longitude coordinates (343212 x 2 double). I want to calculate the distance between each set of coordinates in this matrix and a single reference coordinate. I am using the LatLon Distance function.
What I do not know how to do is loop through each pair of coordinates in the data set so that it returns a vector with the distance between each pair of coordinates and the reference point.
Any help is much appreciated, thank you.
採用された回答
その他の回答 (1 件)
Iddo Weiner
2017 年 1 月 29 日
編集済み: Iddo Weiner
2017 年 1 月 29 日
a = rand(10,2); %change this to your data
out = nan(length(a));
for i = 1:(length(a))
out(i,1) = abs(mean([a(i,1),a(i,2)]) - constant part;
% change this function to the one you want to use, I just invented
% something for the example
end
1 件のコメント
Guillaume
2017 年 1 月 29 日
Please, do not use length on matrices. Your code will fail if the input matrix only has one row (since length will then return the number of columns). Use size with a explicit dimension, in this case size(a, 1).
I wouldn't recommend length for vectors either. numel is safer.
カテゴリ
ヘルプ センター および File Exchange で Coordinate Reference Systems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!