Calculate Mean Score of subjects

4 ビュー (過去 30 日間)
Yeahh
Yeahh 2021 年 11 月 8 日
回答済み: Seth Furman 2021 年 11 月 10 日
Hi,
I need help with reading .txt files and calculate the mean score for subjects. There are four tests, we only want the average of test 1, test 3, and test 4 accross all four subject (1_1, 2_2, 3_3, 4_4). If the subject is absent for that specific test, we marked as '1', for example subject 1_1 is absent for 'test 4' 30 days ago.
If the subject is absent for 'test n' 30 days ago and 30 days after, we will not calculate the average score for this subject. However, if the subject is absent for 'test n' 30 days ago but present 30 days after, we will still calculate the average score for this subject.
Only 4 subject in this data set only, but we are expanding the numbers of data (expecting to be 1000 subjects)

採用された回答

Seth Furman
Seth Furman 2021 年 11 月 10 日
You can
1) find the mean across several variables using mean(t{:, ["Var1", "Var2", "Var3"]}, 2)
2) find rows that meet a certain condition (e.g. absent for both tests) by using logical indexing such as t{t.Condition1 & t.Condition2, "Mean"} = missing.
t = array2table(randi(10, 3, 4))
t = 3×4 table
Var1 Var2 Var3 Var4 ____ ____ ____ ____ 2 1 7 1 2 9 8 9 9 10 9 9
t.Mean = mean(t{:, ["Var1", "Var2", "Var3"]}, 2)
t = 3×5 table
Var1 Var2 Var3 Var4 Mean ____ ____ ____ ____ ______ 2 1 7 1 3.3333 2 9 8 9 6.3333 9 10 9 9 9.3333
t{t.Var1 > 5 & t.Var2 > 5, "Mean"} = missing
t = 3×5 table
Var1 Var2 Var3 Var4 Mean ____ ____ ____ ____ ______ 2 1 7 1 3.3333 2 9 8 9 6.3333 9 10 9 9 NaN

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by