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?
0 个评论
回答(1 个)
José-Luis
2016-9-16
vals = randn(1000,1);
avg = mean(vals);
h = histogram(vals);
legend({sprintf('mean = %3.2f', avg)})
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!