フィルターのクリア

Histc function, bin edges error

1 回表示 (過去 30 日間)
John
John 2013 年 1 月 18 日
Hi,
I am using the code below to overlay a cdf plot on a histogram (top code). I want to specify the bin edges using the histc function (below code). But, I'm getting an error using the histc function below. Would anybody know what I'm doing wrong?
Thanks
[y2,x2] = ecdf(y);
[y1,x1] = hist(y);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
x = 110:10:220;
[y2,x2] = ecdf(y);
[y1,x1] = histc(y,x);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
X must be same length as Y.
Error in @(x,y)bar(x,y,1,'c')

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 1 月 18 日
I think you want to make sure that everything is a row vector or every thing is a column vector.
x = 110:10:220;
[y2,x2] = ecdf(y);
[y1,x1] = histc(y,x);
y1 = y1';
x1 = x1';
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
% Make sure that x1 x2 y1 y2 all are either columns or rows.
  1 件のコメント
John
John 2013 年 1 月 19 日
Hi,
It is still giving an error, "X must be same length as Y".
But x are the bin edges? and y is the data, why would they be the same length?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by