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 Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by