Find corresponding values of discritized data after using splitapply

2 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 24 Aug. 2020
Bearbeitet: Bruno Luong am 24 Aug. 2020
if x is extracted as the first column of your array A
slice_x = splitapply(@(x) {x}, A, disc_x);

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by