fitting a custom curve in histogram

4 次查看(过去 30 天)
cgo
cgo 2015-2-15
Hello,
I have a histogram plot data and I want to fit some curve that is "non-traditional". Instead of the usual normal, beta, etc plots, I want to fit it with something like log(c/x) where c is a constant. Any ideas on how to achieve this?
Thanks

回答(1 个)

Star Strider
Star Strider 2015-2-15
编辑:Star Strider 2015-2-15
One possibility:
bars = randi(20, 1, 5); % Created ‘Histogram’ Data
bins = 1:5;
f = @(c,x) log(c./x);
B0 = rand;
B = nlinfit(bins, bars, f, B0);
figure(1)
bar(bins, bars)
hold on
plot(bins, f(B,bins), '-r', 'LineWidth',1.5)
hold off
You will have to experiment with it to get the result you want. I can only claim that the code I posted here runs!

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by