I am new to Matlab. I want to display the standard deviation and the mean on a histogram. Can i get Matlab to do this without having to insert the values as text manually?

24 次查看(过去 30 天)
The command legend('text') only seems to accept text inputs, is there a way to make it display the mean and/or standard deviation without me having to enter it?

回答(1 个)

José-Luis
José-Luis 2016-9-16
vals = randn(1000,1);
avg = mean(vals);
h = histogram(vals);
legend({sprintf('mean = %3.2f', avg)})

类别

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