Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个尺寸为 1x3000 的向量。我在 Matlab 中使用百分位函数找到了百分位值。但我无法在向量内找到四分位数的索引值。
y = rand(1,3000); Q_2 = prctile(y,50); Idx = find(y==Q_2);
Idx 返回一个空值。我应该能够获得包含中值的索引值。
您可以通过以下方式有效地找到最接近中位数(或任意一个q_2)的条目:
q_2
[~,Idx]=min(abs(q_2-y));
根据help min,返回的值Idx对应于差异向量中具有最小值的第一个元素。
help min
Idx