correlation matrix labels

Assume I have:
names = { 'one', 'two', 'three' };
How could i generate the matrix:
'one vs one' 'one vs two' 'one vs three'
'two vs one' 'two vs two' 'two vs three'
'three vs one' 'three vs two' 'three vs three'
(without a nested for loop of course)

 Respuesta aceptada

Daniel Shub
Daniel Shub el 24 de Mayo de 2012

0 votos

names = {'one', 'two', 'three'};
middle = {' vs '};
N = length(names);
reshape(strcat({names{repmat(1:N, N, 1)}}, middle, {names{repmat(1:N, N, 1)'}}), N, N)'
ans =
'one vs one' 'one vs two' 'one vs three'
'two vs one' 'two vs two' 'two vs three'
'three vs one' 'three vs two' 'three vs three'

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 24 de Mayo de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by