Mean, Max and Min of Structured Cell array
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all, I have a structured cell array where I need to compute the mean of each cell from column 4. Column 3 contains the name of the data (repeated for number of days 31, 29 etc.). At the end I would like to display the results as name (3rd column one value) , Average, Min and Max of each cell of 4th column data. Any help (sample example) in this regard is highly appreciated. For your reference I have attached the picture.
댓글 수: 0
채택된 답변
Matt J
2021년 4월 8일
편집: Matt J
2021년 4월 8일
You should first convert everything to table form.
Column3={{'dog';'dog';'dog'},{'cat';'cat'}}; %Original data
Column4={[1;2;3], [4;5]};
Column3=string( vertcat(Column3{:}) );
Column4=vertcat( Column4{:} );
T=table(Column3,Column4,'VariableNames',{'Names','Data'})
From that point on, it all becomes much easier:
Means = varfun(@mean,T,'GroupingVariables','Names')
Maxs= varfun(@max,T,'GroupingVariables','Names')
댓글 수: 14
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!