필터 지우기
필터 지우기

Make two groups of data from a given data set

조회 수: 1 (최근 30일)
Ali Akber
Ali Akber 2018년 9월 18일
댓글: jonas 2018년 9월 18일
Hi,
I want to separate some specific data from a given data set. Suppose I have data set r i.e.
r = randi(99,1,500);
I want to make two groups of data based on following conditions
if r<=30 make group 1 (store them in an array)
if r>=35 make group 2 (store them in an array)
Any help in this regard will be highly appreciated.

채택된 답변

jonas
jonas 2018년 9월 18일
편집: jonas 2018년 9월 18일
Just use logical indexing. Suppose you have a variable A that you want to group based on the values in r.
B{1}=A(r<=35);
B{2}=A(r>35);
Now you have split the array A and stored the sets in a cell array B. Of course, you can replace A by r, if r is the array you want to group.
Note that your signs were inconsistent.
  댓글 수: 2
Ali Akber
Ali Akber 2018년 9월 18일
Thank you so much. :)
jonas
jonas 2018년 9월 18일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by