# Calculate Mean Score of subjects

4 vues (au cours des 30 derniers jours)
Yeahh le 8 Nov 2021
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)
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Seth Furman le 10 Nov 2021
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Hypothesis Tests dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by