簡體   English   中英

如何在MATLAB中找到最小和最大bin的大小?

[英]How to find the size of smallest and largest bin in MATLAB?

我需要找到具有最大和最小元素的bin大小。 我在MATLAB中使用histc函數。

這是我在做什么

A=[1 2 3 11 22 3 4 55 6 7 2 33 44 5 22]
edges = [10 inf];   
N = histc(A,edges)

得出N = [6,0]; 表示有6個元素的值大於10。現在,我要計算條件中箱中的最大數量。

這里應該是2,因為在兩個實例中我們有兩個滿足我的條件的整數11 2233 44

如何在MATLAB中進行計數。

干得好;

A=[1 2 3 11 22 3 4 55 6 7 2 33 44 5 22]

arr=diff([0 (find(~(A>10))) numel(A)+1]) -1;
arr(find(arr(1,:)==0))=[];

largest=max(arr);   % longest sequence of occurences of numbers > 10
smallest=min(arr);  % smallest sequence of occurences of numbers > 10

干杯!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM