How to run a function over a specified set of variables in a table?

조회 수: 1 (최근 30일)
Tomaszzz
Tomaszzz 2022년 2월 28일
편집: Matt J 2022년 2월 28일
Hi all,
I have a 21x288 table (attached).
I have a function that compares the variables and calculates the interclass correlation coefficient. I would like to have a code that will run the function over the following set of columns:
1 vs 2
1 vs 3
1 vs 4
5 vs 6
5 vs 7
5 vs 8
9 vs 10
9 vs 11
9 vs 12
and so on until the end of the table
I could do it by creating a seperate matrix from the specified variables in the table and running the function over it. Would there be a more efficient way to do this?
1vs2 = data(:,1:2);
[r] = ICC(1vs2);

채택된 답변

Matt J
Matt J 2022년 2월 28일
편집: Matt J 2022년 2월 28일
The more efficient way would be to write ICC to support two multi-column inputs. Then, process the data in 3 subsets, as below:
data1=data(:,1:4:end);
r=cell(1,3)
for i=1:3
data2 = data(:,i+1:4:end);
r{i} = ICC(data1,data2);
end

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by