Find corresponding values of discritized data after using splitapply

조회 수: 2 (최근 30일)
Tessa Kol
Tessa Kol 2020년 8월 24일
댓글: Tessa Kol 2020년 8월 24일
I have a 3384x5 array of which the first and last 20 rows are shown in the pictures below.
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...
Problem: How can I retrieve the values of the 2nd column and 3th that correspond to the grouped data of column 1?

채택된 답변

Bruno Luong
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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by