如何在 Matlab 中找到最小的 10% 的数据?

How to find the minimum 10th percent of data in Matlab?

我有一个数据向量 [224x1] 和另一个匹配的时间向量 [224x1]。我想找到占据数据最低 10% 的最小值。我怎样才能找到匹配的时间?

我尝试使用排序功能(来自此处:https://www.mathworks.com/matlabcentral/answers/249619-how-do-i-get-the-top-10-percent-of-the-matrix-value),但时间不再按时间顺序排列。这是我使用的代码:

[sortedValues,sortIndex] = sort(THUL_ST_JJA(:),'ascend'); %Sort Ascending
[sortedDTValues,sortDTIndex] = sort(THUL_dt_JJA(:),'ascend'); %Sort Ascending

idx = sortIndex(1:ceil(length(sortIndex)*0.1)); %Minimum 10th percent STs
THUL_ST_min = THUL_ST_JJA(idx);
THUL_dt_min = THUL_dt_JJA(idx); %Find matching 10th percent minimum times 

这是时间(mm/dd/yyyy hh:mm:ss)和温度的样本:

06/08/2012 07:00:00 -5.26
06/08/2012 10:00:00 -5.18
06/08/2012 09:00:00 -5.1
06/08/2012 08:00:00 -5.07
06/08/2012 06:00:00 -4.84
06/08/2012 11:00:00 -4.84
06/09/2012 06:00:00 -4.84
06/09/2012 07:00:00 -4.82
06/09/2012 05:00:00 -4.79
06/09/2012 08:00:00 -4.65
08/29/2012 05:00:00 -4.61
06/09/2012 09:00:00 -4.49
08/29/2012 06:00:00 -4.47

对数据进行排序。然后使用相同的索引对时间进行排序。这使对保持在一起。

然后获取所需数据的索引并将相同的索引应用于时间。

[sortData, sortIDX] = sort(rawData,'ascend');
sortTime            = rawTime(sortIDX);

bottom10IDX = 1:ceil(length(sortData)*0.1);
bottom10Data = sortData(bottom10IDX);
bottom10Time = sortTime(bottom10IDX);