필터 지우기
필터 지우기

Rows in a matrix with a certain outcome

조회 수: 1 (최근 30일)
Daniel Ring
Daniel Ring 2018년 10월 15일
답변: dpb 2018년 10월 15일
I have a matrix with 16 columns and a large number of rows. In each column, there is one of two outcomes (ex: one column is filled with ones and zeros, another column is filled with 0.4s and 0.6s). I am looking for a function that can count the number of rows in which a combination of outcomes occurs. For example, I'd like to figure out how many rows have ones, .6s, and .7s.
ex:
1 .7 .6 (random numbers 4-16)
1 .3 .4 (random numbers 4-16)
1 .3 .6 (random numbers 4-16)
1 .7 .6 (random numbers 4-16)
1 .7 .4 (random numbers 4-16)
ans = 2

채택된 답변

dpb
dpb 2018년 10월 15일
>> sum(ismember(sort(x,2),[.6 .7 1],'rows'))
ans =
2
>>
Generalize the set looking for instead of using the hardcoded values, of course...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by