Calculate Mean Score of subjects
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
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.Mean = mean(t{:, ["Var1", "Var2", "Var3"]}, 2)
t{t.Var1 > 5 & t.Var2 > 5, "Mean"} = missing
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!