MATLAB Answers


Group and individual means

Liz Mat 님이 질문을 제출함. 9 Jul 2019
최근 활동 Liz Mat 님이 댓글을 추가함. 12 Jul 2019
I have a dataset of kinematic angular values. Each row representing 100 datapoints of angular data (Y). I have a column vector containing my subject numbers (1-9) and another column vector indicating three different conditions (A).
I am able to calculate the group mean for each
YS1 = Y(Sub==1)
SubMean = mean (Y1S)
(All conditions, 1 subject)
Same for condition mean
YA1 = Y(A==1)
SubMean = mean (YA1)
(All subjects, 1 condition)
How can I combine it to to get the mean for 1 subject AND 1 condition - Thus (Sub==1) AND (A==1)

  댓글 수: 0

로그인 to comment.

답변 수: 2

per isakson 님의 답변 9 Jul 2019
 채택된 답변

Try this
YSA1 = Y(Sub==1&A==1);
SubMean = mean (YSA1);

  댓글 수: 3

Thanks for the quick response
This is the error I get:
YSA1 = Y(SUBJ==1,: & A==32,:);
Error: Invalid use of operator.
When I try:
YSA1 = Y(SUBJ==1,:) && Y(A==32,:);
I get the error:
Operands to the || and && operators must be convertible to logical scalar values.
My variables are:
SUBJ = 135x1
A = 135x1
Y = 135x101
YSA1 = Y(SUBJ==1,: & A==32,:);
YSA1 = Y( SUBJ==1 & A==32 );
i.e. remove the commas and the colons. See my answer
Thank you!

로그인 to comment.

Liz Mat 님의 답변 10 Jul 2019

I managed to get it working:
SA1 = (Sub==1)&(A==1);
YSA1 = Y(SA1,:);
SubMean = mean (YSA1);
It might be bit lengthy though.

  댓글 수: 1

The parentheses in SA1 = (Sub==1)&(A==1); are not needed.

로그인 to comment.

Translated by