フィルターのクリア

Extract data from a histogram from a certain range on the x-axis

5 ビュー (過去 30 日間)
jgillis16
jgillis16 2015 年 7 月 29 日
コメント済み: Heejung Jung 2020 年 5 月 8 日
I am trying extract data from a histogram on a certain range on the x-axis without going in individually and counting the 'binned' data using the data cursor. Is there any way on how to do this?
  3 件のコメント
jgillis16
jgillis16 2015 年 7 月 29 日
hist()
Image Analyst
Image Analyst 2015 年 7 月 30 日
Attach a diagram. I don't know what you mean. Do you have a 1-D vector of numbers, a 2-D image, or what? If you have just a 1-D list of numbers, then the "x" axis is just the index, and the "y" value is the value of the array, so what does a hist of the x-axis mean in that case? A histogram of the indexes would just be a vector of all 1's since each index appears just once. Even for a 2D array, I don't know what a "histogram on a certain range on the x-axis" means. Do you mean a histogram of image values only between column #1 and column #2?

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

採用された回答

Walter Roberson
Walter Roberson 2015 年 7 月 30 日
The easiest way is to store the output of the hist() call, which will be the counts (or the counts and the centers if you have two outputs.) You can then bar() the graph into existence:
[counts, centers] = hist(YourData);
bar(centers, counts, 'hist');
Failing that, if you really need to pull data out of an existing hist(), then:
histpatch = findobj(gca, 'type', 'patch');
edgemat = get(histpatch, 'XData');
countmat = get(histpatch, 'YData');
counts = countmat(2,:);
centers = mean(edgemat(2:3,:));
  4 件のコメント
Avinash Bhatt
Avinash Bhatt 2019 年 5 月 3 日
what countmat(2,:) mean?
Heejung Jung
Heejung Jung 2020 年 5 月 8 日
How do you do the same thing if histogram() was used instead of hist()?

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

その他の回答 (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