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

1 次查看(过去 30 天)
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