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

1 view (last 30 days)
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);

Accepted Answer

Matt J
Matt J on 28 Feb 2022
Edited: Matt J on 28 Feb 2022
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

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!