Help with acquiring means of different columns using on one single matlab code

1 view (last 30 days)
kklkj

Accepted Answer

Giorgos Papakonstantinou
Giorgos Papakonstantinou on 6 Mar 2014
  • For the first question:
ismember(Gender, 'Male')
Will give a logical vector with true(1) the males and false(0) the females. With this logical vector you can index the columns which refer to the response times of the males.
ResponseTimes(:,ismember(Gender, 'Male'))
This will build the matrix with the response times of all males
Now you only have to take the mean in each column of the previous matrix
MeanResponseTimeofMales = mean(ResponseTimes(:,ismember(Gender, 'Male')))
  • For the second question:You have to build a logical matrix that will indicate which response times are above 2.5. Similarly you do this by:
ResponseTimes>2.5
The true values (1) will be the ones above 2.5 and the false values (0) will be the ones less or equal to 2.5.
Now simply you need to find if ANY of the columns have at least one true value. You do this by logical indexing:
any(ResponseTimes>2.5)
Now, since you know which columns have at least one true value you must use the previous logical vector to index your Name cell.
Names(any(ResponseTimes>2.5))
but read about logical indexing, ismember and any. And as Walter said, spend some time reading the how-to-ask-questions tutorial

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!