Separate and Operate on Cells Based on Label

조회 수: 2 (최근 30일)
Brian Tomblin
Brian Tomblin 2016년 7월 8일
댓글: Brian Tomblin 2016년 7월 12일
Hello,
I need assistance with separating out a cell array consisting of text labels within each cell based on the label. I have tried the findgroups function, but I would like to have the labels remain for further operations instead of the generated numbers for the labels (for example, I'd want to work with group "bicep" instead of group "1"). If I am misunderstanding how findgroups works and that is a possible outcome with that function, please explain how, as I am still new to Matlab.
Secondly, once those cells are separated based on the label, I need some way to go through all of the groups separately with a function (in this case, a mean of the unique values in corresponding cells). I understand how to do the function if all values were in the same group, but I am confused if working with numerous groups at the same time.
If there's anything else needed to help with my case, please ask and I can give more information. Thank you. (see comments)
  댓글 수: 6
per isakson
per isakson 2016년 7월 12일
편집: per isakson 2016년 7월 12일
"I'd want to work with group "bicep" instead of group "1"" &nbsp means that you you want to use statements like
plot( ..., 'bicep' )
How large is the total dataset, typically?
Brian Tomblin
Brian Tomblin 2016년 7월 12일
It can vary depending on how much data is given. Currently working with around 14 labels. A way to group the data such that naming each individual label during plotting would be unnecessary would be nice, if possible. Along the idea that the groups are separated, but still remain under a variable LABELS or something like that, so plot(Labels) would go through each group individually and plot them without having to name them. If that's not a possibility, it can be worked around.

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

답변 (1개)

Image Analyst
Image Analyst 2016년 7월 10일
Try the ismember() function. To get the means, you can use grpstats().
  댓글 수: 3
Stephen23
Stephen23 2016년 7월 11일
편집: Stephen23 2016년 7월 11일
Have a look at ismember's second output. You could use that output in accumarray to group/process your data together.
Brian Tomblin
Brian Tomblin 2016년 7월 11일
편집: Brian Tomblin 2016년 7월 11일
Using the Lia or Lia,Locb function requires a string instead of cells, which doesn't work due to the long list of text that ends up in a single cell. I cannot seem to find the members when all of them are together in the same cell. Possibly text was not intended for the ismember() function.

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

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by