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

4 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Matt J
Matt J il 28 Feb 2022
Modificato: Matt J il 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

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by