フィルターのクリア

How can I create binEdges?

4 ビュー (過去 30 日間)
gjashta
gjashta 2020 年 3 月 12 日
コメント済み: J. Alex Lee 2020 年 3 月 12 日
I have the Data below and I want to create bins that vary from the lowest to the highest value of the Data(:,2) and I am using
the code as following but I get bins with zero members and that is not what I want.
First:
How can I create a set of bins that have always more than two members on it?
Second:
How to use the same binEdges but binning the first 150 values of the Data(:,2) with more than 2 members per bin?? And then doing the same thing and same binEdges but using the second 150 values of the Data(:,2)??
price=Data(:,1);
topEdge1=max(Data(:,2));
botEdge1=min(Data(:,2));
NumBins=30;
binEdges1=linspace(botEdge1, topEdge1, NumBins);
[h, WhichBin]= histc(Data(:,2),binEdges1);
for i = 1:Numbin
BinMembers=(WhichBin==i);
binMembers=price(BinMembers);
binMean1(i)=mean(binMembers);
binstd1(i)= std(binMembers);
end

採用された回答

J. Alex Lee
J. Alex Lee 2020 年 3 月 12 日
It looks like your problem is not with binning, but the fact that you have NaN's in your data.
By the way if you have 2014b or later, probably better to switch to histcounts.
  2 件のコメント
gjashta
gjashta 2020 年 3 月 12 日
I have used histcounts but there are bins with zero values on it and I
also cannot use the same bindEdges for smaller samples of Data(:,2).
J. Alex Lee
J. Alex Lee 2020 年 3 月 12 日
Look for NaN's in your data. As I said, your problem is not with binning.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by