Excel:OFFSET / TRANSPOSING创建距离矩阵

时间:2017-07-10 08:09:28

标签: excel excel-formula

我有~90个位置的列表,我需要计算这些位置之间的鹰眼距离。我使用以下公式来计算以英里为单位的距离:

=ACOS(COS(RADIANS(90-$F3))*COS(RADIANS(90-$F$2))+SIN(RADIANS(90-$F3))*SIN(RADIANS(90-$F$2))*COS(RADIANS($G3-$G$2)))*3958.756

Sample

我的想法是,一旦我拥有了H列的所有公式,我只需要向右拖动列并固定新位置,这样当矩阵中的位置与自身匹配时,距离将是零。

我一直在尝试使用TRANSPOSE和OFFSET而没有任何成功,任何想法?

2 个答案:

答案 0 :(得分:0)

输入

=IF(ROW(A1)>COLUMN(A1),ACOS(COS(RADIANS(90-$F2))*COS(RADIANS(90-INDEX($F$2:$F$5,COLUMN(A1))))+SIN(RADIANS(90-$F2))*SIN(RADIANS(90-INDEX($F$2:$F$5,COLUMN(A1))))*COS(RADIANS($G2-INDEX($G$2:$G$5,COLUMN(A1)))))*3958.756,"")
H2中的

(此单元格将为空)并将其复制/拖动以填充 整个表H2:K5(一些随机lon/lat):

enter image description here

此处ROW(A1)COLUMN(A1)是一种使用i,j索引的懒惰方式 表元素。

以防万一,结构化形式的相同公式:

IF(
  ROW(A1)>COLUMN(A1),
  ACOS(COS(RADIANS(90-$F2))*COS(RADIANS(90-INDEX($F$2:$F$5,COLUMN(A1))))
    +SIN(RADIANS(90-$F2))*SIN(RADIANS(90-INDEX($F$2:$F$5,COLUMN(A1))))
    *COS(RADIANS($G2-INDEX($G$2:$G$5,COLUMN(A1)))))*3958.756,
  ""
)

答案 1 :(得分:0)

这是我的建议

=ACOS(COS(RADIANS(90-D$2))*COS(RADIANS(90-$B4))+SIN(RADIANS(90-D$2))*SIN(RADIANS(90-$B4))*COS(RADIANS(D$3-$C4)))*3958.756

enter image description here