필터 지우기
필터 지우기

correlation matrix labels

조회 수: 2 (최근 30일)
Walter
Walter 2012년 5월 24일
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)

채택된 답변

Daniel Shub
Daniel Shub 2012년 5월 24일
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'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by