How to make an histogram of functions?

1 回表示 (過去 30 日間)
Douglas Aguiar
Douglas Aguiar 2017 年 8 月 1 日
回答済み: Douglas Aguiar 2017 年 8 月 1 日
I need to be able to see a region in which a family of functions is "passing by" as a function of another parameter. The code below should be able to illustrate what I need.
clear;
wl_tst = 1.51:1e-3:1.58;
low = -5e-3;
up = 5e-3;
N = 100;
r = low + (up-low).*randn(N,1);
figure(1)
clf;
for i=1:length(r)
A = [1.57 1; 1.52 1]+[r(i) 0;r(i) 0];
B = [0.54;0.42];
C = A\B;
slope = C(1);
avg = C(2);
plot(wl_tst,slope*wl_tst+avg);
dat(i,:) = slope*wl_tst+avg;
hold on
end
xlim([1.52 1.57]);
grid minor
grid on
I would like to have a histogram plot, with this same axes, but that in the Z axis, show me the count of times that any of the functions passed by that bin.
Any ideas on how to generate that?
I tried briefly to use the histogram2 function, by am afraid it will not help...

採用された回答

Douglas Aguiar
Douglas Aguiar 2017 年 8 月 1 日
Found a way:
figure(2)
clf;
edges = 0.3:0.005:0.65;
map = zeros(length(wl_tst),length(edges)-1);
for i=1:length(wl_tst)
[count, edge] = histcounts(dat(:,i),edges);
map(i,:) = count;
end
pcolor(wl_tst,edges(1:end-1),map')
colormap(jet(1024));
shading interp;

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