Is there a way to extracted histogram data into a matrix instead of graph?
21 次查看(过去 30 天)
显示 更早的评论
Hello,
Is there a way to extract histogram data into a matrix instead of a graph?
for mer= start:Add:N_Mer
FileName_1 = ['Info_',num2str(N_Mer),'.mat'];
disp([FileName_1,' Running'])
M=load(FileName_1);
all_rows=cell2mat(struct2cell(M));
R_sqr{N_Mer}=all_rows(1,:);
FileName=(['hist_R2',num2str(N_Mer)]);
hist_R2{N_Mer}=histogram(R_sqr{N_Mer});
legend
hold on
end
0 个评论
采纳的回答
Bryan
2019-11-22
编辑:Bryan
2019-11-22
If you want to make a plot and also extract the values
% some data
foo = randn(10000,1);
% make a histogram named h
h = histogram(foo);
% get the values of the histogram
binedges = h.BinEdges;
binwidth = h.BinWidth;
bincounts = h.Values;
Alternatively, if you don't want a plot, but just want to extract histogram information
% some data
foo = randn(10000,1);
% extract histogram data
[bincounts, binedges] = histcounts(foo);
7 个评论
Steven Lord
2019-11-22
The bin counts are fence rails/sections, the bin edges are the fence posts. See the Wikipedia page for "off by one error".
Ten bins would require eleven bin edges as shown in the picture in the "Fencepost error" section on that Wikipedia page.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!