Find corresponding values of discritized data after using splitapply
2 次查看(过去 30 天)
显示 更早的评论
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?
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 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!