fitting a custom curve in histogram
Afficher commentaires plus anciens
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
Réponses (1)
Star Strider
le 15 Fév 2015
Modifié(e) : Star Strider
le 15 Fév 2015
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!
Catégories
En savoir plus sur Exploration and Visualization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!