Effacer les filtres
Effacer les filtres

correlation matrix labels

2 vues (au cours des 30 derniers jours)
Walter
Walter le 24 Mai 2012
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)

Réponse acceptée

Daniel Shub
Daniel Shub le 24 Mai 2012
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'

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by