How to generate all pairwise differences between two vectors

12 visualizaciones (últimos 30 días)
Tamir Eisenstein
Tamir Eisenstein el 6 de Feb. de 2019
Respondida: Andrei Bobrov el 15 de Feb. de 2019
Hi,
how can I generate a new vector of all the pairwise differences between two existing vectors?
thanks,
Tamir

Respuestas (4)

Andrei Bobrov
Andrei Bobrov el 6 de Feb. de 2019
out = a(:) - b(:)';

Tamir Eisenstein
Tamir Eisenstein el 7 de Feb. de 2019
Thanks Andrei!

Tamir Eisenstein
Tamir Eisenstein el 15 de Feb. de 2019
Editada: Tamir Eisenstein el 15 de Feb. de 2019
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 el 15 de Feb. de 2019
out = (a(:)' - b(:))./b(:)*100;

Categorías

Más información sobre Oil, Gas & Petrochemical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by