MATLAB Answers

Does 'i' after value stand for 'index', and if so why does it appear as part of the answer?

1 ビュー (過去 30 日間)
Alexander Eaton
Alexander Eaton 2018 年 3 月 24 日
コメント済み: Alexander Eaton 2018 年 3 月 25 日
I am trying to calculate the Euclidean distance between two images vectors of 4096 values that are contained in a file called allData (see pic) with the command:
Dist = sqrt(sum((allData(1) - allData(3) .^ 2)))
the answer that was returned was
0.0000 +19.1794i
does this answer seem correct or is the 'i' returned because im indexing into a matrix and im just getting returned one of the values from that image vector or am i being returned the distance between the two rows?

採用された回答

Roger Stafford
Roger Stafford 2018 年 3 月 24 日
編集済み: Roger Stafford 2018 年 3 月 24 日
The 'i' in your result indicates a complex answer. I assume you are familiar with complex numbers. The 'i' represents the square root of minus one. This is caused by your attempt to take the square root of a negative number. Apparently allData(1) is less than the square of allData(3).
  5 件のコメント
Alexander Eaton
Alexander Eaton 2018 年 3 月 25 日
thank you Roger for all your help

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by