Histograms - Mean calculation - Comparing more pdf
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Gianluca Borgna
il 25 Mar 2019
Commentato: Gianluca Borgna
il 26 Mar 2019
Hi everyone!
I have 3 questions!
1) I would like to do an histogram in which i have numbers in ordinates and names in absissae. I have no idea how to do it in Matlab.
2) I need a graph in which i plot how the mean stablizes itself as a function of the sampling.
I have 100 values and i should take the mean progressively.
For example [1 2 3 4].
I need a vector that take the mean [mean(1), mean (1+2), mean (1 + 2+ 3), mean (1+2+3+4)]. How to do that?
3) I'm comparing 2 probability density functions and i would like to know if it is possible to use different colors in the zone in common between the 2 histograms.
What Matlab does it is just to blaken the zone. I would like to know if it is possible to choose different colors.
Thanks in advance!
0 Commenti
Risposta accettata
Rik
il 25 Mar 2019
data=rand(100,1);
%make sure to only input vectors
prog_mean=cumsum(data)./cumsum(ones(size(data)));
As for your third question, please post the code you use. It is often easier to adapt code that almost does what it needs to do, then guess your data structure and appropriate code.
5 Commenti
Rik
il 26 Mar 2019
I prefer setting the DisplayName property in my calls to plot and then only turning the legend on. You can also do it differently, please read the doc for the legend function. Matlab documentation is actually pretty good. You will find several examples there, including the allowed forms of syntax.
The code below should give you an idea as well. Also: try using arrays of handles, instead of numbered variables. Numbered variables are generally a bad idea.
f=[];%clear f in case it already exists to prevent unexpected outcomes
figure; histogram(af_Caramagna,CaramagnaEdges,'Normalization','pdf','FaceColor',[0.3010 0.7450 0.9330]);
hold on; f(1)=plot(CaramagnaEdges, Caramagna_distr, 'linewidth',2, 'color','b'); grid minor;
hold on;
histogram(af_CaramagnaDeg1,CaramagnaEdges,'Normalization','pdf','FaceColor','r');
f(2)=plot(CaramagnaEdges, CaramagnaDeg1_distr, 'linewidth',2, 'color','r');
legend(f,...
['\mu = ' num2str(round(Caramagna_mean,2)) ' \sigma = ' num2str(round(Caramagna_std,2)) ' CoV = ' num2str(round(Caramagna_cov,2))], ...
['\mu = ' num2str(round(CaramagnaDeg1_mean,2)) ' \sigma = ' num2str(round(CaramagnaDeg1_std,2)) ' CoV = ' num2str(round(CaramagnaDeg1_cov,2))], ...
'orientation','vertical','location','eastoutside');
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!