How to find out if subset of data is or ins't greater than an altered mean value

I have a large matrix with each row representing a data sample and the columns the information of that data sample. Columns 14:37 of the data represent different chlorophyll concentrations for the sample. I need to find out which samples have chlorophyll concentrations greater than 1.5 of the mean in the upper quarter of the sample (so at least one column for that sample between columns 14:19 have a chlorophyll concentration greater than 1.5 of that of the mean chlorophyll concentration (mean of rows 14:37)). The data which does have a chlorophyll concentrations greater than 1.5 of that of the mean in this upper quartile needs to be given a 1 (for yes) and those that don't a 0 (for no). How would I go about doing this?
Thanks,
Natalie

댓글 수: 1

Here is an example of what I mean:
If one of the rows of chlorophyll data was [1,1,2,0,3,4,3,2,1,0,0,0,0,4,0,1,0,2,0,3,3,3,5,2] the mean of chlorophyll data would be 1.6667. I want to know if any of the the first 6 columns of this row have a number that is greater than 1.5 of the mean, so greater than 2.5. There are numbers greater than 2.5 in the first 6 columns and rather than getting back a matrix of [0,0,0,0,1,1], I would like to just get back a matrix of 1, saying that in those 6 columns there is at least one number that is greater than 1.5 times that of the mean.
I hope that is a little clearer as to what I meant
Thanks,
Natalie

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2014년 1월 14일
편집: Matt J 2014년 1월 14일
thresh=mean(data(:,14:37),2)*1.5;
data(:,14:19)=bsxfun(@ge, data(:,14:19) , thresh);

댓글 수: 1

Thank you so much! I had to add in some things. After this I went:
sum_data = sum(data(:,14:19); presence = sum_data>.5;
Thank you again,
Natalie

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mischa Kim
Mischa Kim 2014년 1월 14일
편집: Mischa Kim 2014년 1월 14일
Hello Natalie,
does this help?
A = [0 1 2;2 3 0;3 0 2]
A =
0 1 2
2 3 0
3 0 2
>> B = A(2:3,:) > 1.5
B =
1 1 0
1 0 1
In the above statement I am comparing all entries in rows 2 and 3 and all columns to 1.5.

댓글 수: 2

Sorry, my description probably wasn't clear enough. I don't want to know what numbers are greater than 1.5, I want to know what numbers are greater than 1.5 of the mean. So just say one row of chlorophyll data was [1,1,2,0,3,4,3,2,1,0,0,0,0,4,0,1,0,2,0,3,3,3,5,2] the mean of chlorophyll data would be 1.6667. I want to know if any of the the first 6 columns of this row have a number that is greater than 1.5 of the mean, so greater than 2.5. There are numbers greater than 2.5 in the first 6 columns and rather than getting back a matrix of [0,0,0,0,1,1], I would like to just get back a matrix of 1, saying that in those 6 columns there is at least one number that is greater than 1.5 times that of the mean.
I hope that is a little clearer as to what I meant
Thank you,
Natalie
data = [0 1 2 3 4 5 6;2 3 2 3 0 0 0;0 0 0 0 0 0 0];
for ii = 1:length(data(:,1))
flag(ii) = double(sum(data(ii,1:6)>1.5*mean(data(ii,:))) > 0);
end
flag_data = [flag' data];

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2014년 1월 14일

댓글:

2014년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by