Find corresponding values of discritized data after using splitapply
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 3384x5 array of which the first and last 20 rows are shown in the pictures below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/350975/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/350978/image.png)
With the help of Cris LaPierre I was able to discretize my data (https://nl.mathworks.com/matlabcentral/answers/583103-find-maximum-value-of-array-within-specified-range-consecutively?s_tid=prof_contriblnk)
I wanted to do a similar process as in the mentioned in the link.
Code so far:
% % Define edges of ranges
rng_x = -0.06:0.011:0.061;
% Assign the data of column 1 to a predefined range
disc_x = discretize(x,rng_x);
% Group the data of column 1
slice_x = splitapply(@(x) {x},x,disc_x);
As can be seen in the figure below the splitapply did what I intented it to be, it grouped the data of column 1 in each defined range. Thus:
Every value of column 1 lying between -0.06 and -0.049 is grouped into the first cell (269x1 double)
Every value of column 1 lying between -0.049 and -0.038 is grouped into the second cell (340x1 double)
And so on...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/350981/image.png)
Problem: How can I retrieve the values of the 2nd column and 3th that correspond to the grouped data of column 1?
댓글 수: 0
채택된 답변
Bruno Luong
2020년 8월 24일
편집: Bruno Luong
2020년 8월 24일
if x is extracted as the first column of your array A
slice_x = splitapply(@(x) {x}, A, disc_x);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!