How would i generalize the following variables

1 回表示 (過去 30 日間)
Feliciano Döring
Feliciano Döring 2018 年 4 月 4 日
編集済み: Matt J 2018 年 4 月 4 日
I want to generalize the following variables
dat=norm(A(:,5)-A(:,1));
dbt=norm(A(:,5)-A(:,2));
dct=norm(A(:,5)-A(:,3));
ddt=norm(A(:,5)-A(:,4));
i already tried doing it like this,
dt=norm(A(:,5)-A(:,1:4));
but i want it to calculate for each element, so how would it do it?

採用された回答

Matt J
Matt J 2018 年 4 月 4 日
Using the attached file,
G = interdists(A)
will return a matrix G(i,j)=norm(A(:,i)-A(:,j)).
  2 件のコメント
Feliciano Döring
Feliciano Döring 2018 年 4 月 4 日
編集済み: Feliciano Döring 2018 年 4 月 4 日
I think that goes a little above of what i want. I have these four variables dat,dbt,dct and ddt and i want just their value. The thing is if i want more variables with these similar formulas how would the code look like i'm trying to reduce the work i have in typing them every time whilst they look alike.
Matt J
Matt J 2018 年 4 月 4 日
編集済み: Matt J 2018 年 4 月 4 日
You can use the two-argument form of interdists to get more restricted results.
dt = interdists(A(:,1:4),A(:,5))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by