フィルターのクリア

distance between the rows of a matrix and the mean

2 ビュー (過去 30 日間)
pavlos
pavlos 2012 年 2 月 29 日
Hello,
Consider a 100x20 matrix.
How`s the euclidean distance between each row (1x20) and the mean (average) of the rows (1x20) is calculated?
Thank you.
Best,
Pavlos

採用された回答

Walter Roberson
Walter Roberson 2012 年 2 月 29 日
For the situation you describe:
size = nthroot(sum(realpow(bsxfun(@plus,-Rows,mean(Rows)),ndims(Rows)),ndims(Rows)),ndims(Rows));
There are more compact ways to express this, and there are code sequences that are faster, but this particular code sequence is constructed for higher accuracy.
(This particular code sequence is also constructed to be a heartache to anyone using it for homework without understanding it thoroughly. Markers will not be amused.)
  2 件のコメント
pavlos
pavlos 2012 年 3 月 1 日
Thank you very much.
It works great, but the code line is to long to include it
in a script file.
Best,
Pavlos
Walter Roberson
Walter Roberson 2012 年 3 月 1 日
The line length restriction in script files and function files is about 40000 characters.
Besides, if you are doing an assignment that prohibits you from writing function files, then you have bigger problems to deal with than a long line of code.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePhased Array Design and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by