How to generate all pairwise differences between two vectors

12 ビュー (過去 30 日間)
Tamir Eisenstein
Tamir Eisenstein 2019 年 2 月 6 日
回答済み: Andrei Bobrov 2019 年 2 月 15 日
Hi,
how can I generate a new vector of all the pairwise differences between two existing vectors?
thanks,
Tamir

回答 (4 件)

Andrei Bobrov
Andrei Bobrov 2019 年 2 月 6 日
out = a(:) - b(:)';

Tamir Eisenstein
Tamir Eisenstein 2019 年 2 月 7 日
Thanks Andrei!

Tamir Eisenstein
Tamir Eisenstein 2019 年 2 月 15 日
編集済み: Tamir Eisenstein 2019 年 2 月 15 日
Hi Andrei, I have a small follow-up question:
How can I generate each difference value in "out" to be a percentage from b [i.e ((a-b)/b)*100 ] and not as a "raw" value?
Thanks!
Tamir

Andrei Bobrov
Andrei Bobrov 2019 年 2 月 15 日
out = (a(:)' - b(:))./b(:)*100;

カテゴリ

Help Center および File ExchangeOil, Gas & Petrochemical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by