フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

[ Help ] Basic MATLAB " For statement "

1 回表示 (過去 30 日間)
sese
sese 2012 年 7 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello Guys
Can you please tell me whether this Matlab code whether correct or not??
this code use to calculate all distances from A to J points on the map ( has longitude and latitude ), the starting point coordinates ( Lat and Long ) is 3.682043 and 101.523710 and the destination is 2.227804 103.35091
for p1=3.682043:-0.5:2.227804
for p2=101.523710:0.5:103.735091
a5= 2.227804;
b5=103.35091;
[dDgree] = distance(p1,p2,a5,b5); %%this function used to find a distance between two coordinates
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 7 月 29 日
No, that code would calculate the distances over a grid of points, not over a list of points with specific locations. Also, that code will throw away the distances after it calculates them.
Suppose you have a vector of length 10 for latitudes, and another for longitudes. lats(1) corresponds to A's latitude, lats(2) for B's lat, longs(1) for A's long, and so on. Then
a5= 2.227804;
b5=103.35091;
for K = 1 : length(lats)
thislat = lats(K);
thislong = longs(K);
dDgree(K) = distance(thislat, thislong, a5, b5);
end
  2 件のコメント
sese
sese 2012 年 7 月 29 日
Thanks Walter Roberson: please brother i am new in Matlab, i am 16 Years old, can you please explain to me more? could you please demonstrate with details? Tq

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by