필터 지우기
필터 지우기

histc removed by matlab

조회 수: 2 (최근 30일)
topolowa
topolowa 2016년 10월 20일
댓글: topolowa 2016년 10월 20일
Hi,
it seems that matlab decided to remove histc and suggests to use histcounts instead. I am often usin histc as follows : [bincounts,ind]= histc(___); It seems, that histcounts does not give indices ind as outputs. I use ind from histc in many codes for various applications, e.g. with accumarray.
Is there any function which would replace histc and give ind as output?
thanks
ina

채택된 답변

Steven Lord
Steven Lord 2016년 10월 20일
The histc function still exists, but we recommend you use histcounts and/or histogram instead.
The third output from histcounts is the equivalent of the second output from histc, assuming you've modified how you specify your bins from bin centers (used by histc) into bin edges (used by histcounts) as described in the "Convert Bin Centers to Bin Edges" example on this page in the documentation.
  댓글 수: 1
topolowa
topolowa 2016년 10월 20일
Perfect! thank you, I should have noticed bin value in the output... thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

John D'Errico
John D'Errico 2016년 10월 20일
편집: John D'Errico 2016년 10월 20일
Why do people never read the help? The MATLAB gods put it there for a reason, of this I am sure. :)
[N,EDGES,BIN] = histcounts(...) also returns an index array BIN, using
any of the previous syntaxes. BIN is an array of the same size as X
whose elements are the bin indices for the corresponding elements in X.
The number of elements in the kth bin is NNZ(BIN==k), which is the same
as N(k). A value of 0 in BIN indicates an element which does not belong
to any of the bins (for example, a NaN value).
Look at the THIRD output from histcounts. It does what you want. You can always discard the first and second return arguments if you only want the third.
[~,~,bins] = histcounts(stuff);

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by