필터 지우기
필터 지우기

How to group same value data

조회 수: 15 (최근 30일)
barath manoharan
barath manoharan 2023년 1월 25일
댓글: barath manoharan 2023년 2월 9일
Iam having 2 6*1 matrix. Now i need to group elements in matrix A based on same value. then i need to choose corresponding elements from matrix B.
For example
A = [0.367;0.264;0.264;0.2345;0.2345;0.367]
B = [01111;00111;10011;10010;10000;01110]
expected output :
group 1 : 0.367
01111,01110
group 2 : 0.264
00111,10011
group 3 : 0.2345
10010,10000
  댓글 수: 2
Stephen23
Stephen23 2023년 1월 25일
편집: Stephen23 2023년 1월 25일
Numeric data types do not store leading zeros, so what is this array really?:
B = [01111;00111;10011;10010;10000;01110]
Is it in fact a character array or a string array or a categorical array or something else?
Dyuman Joshi
Dyuman Joshi 2023년 1월 25일
OP could be trying to store binary representation of numbers as numeric data.

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

채택된 답변

Matt J
Matt J 2023년 1월 25일
G=findgroups(A(:));
splitapply(@(x){x}, B(:),G)
  댓글 수: 1
barath manoharan
barath manoharan 2023년 2월 9일
Thank you and your code works as per my requirement

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by