필터 지우기
필터 지우기

How to generate all pairwise differences between two vectors

조회 수: 15 (최근 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 CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by