how to get outputs from normal distribution fitdist to display in my plot title using sprintf
조회 수: 5 (최근 30일)
이전 댓글 표시
trying to use sprintf to plot the values of mu and sigma in my title for my histogram plot. Mu and sigma are the outputs from the pd=fitdist(data,'normal'). Any suggestions appreciated! Thanks!
this is what I have;
histfit(data,20)
pd = fitdist(data,'normal')
xlabel('Energy in eV')
ylabel('Count Rate')
댓글 수: 0
채택된 답변
Image Analyst
2023년 2월 13일
편집: Image Analyst
2023년 2월 13일
Try this:
data = randn(5000, 1);
histfit(data,20)
pd = fitdist(data,'normal')
fontSize = 18;
grid on;
caption = sprintf('Mu = %f. Sigma = %f', pd.mu, pd.sigma);
title(caption, 'FontSize', fontSize)
xlabel('Energy in eV', 'FontSize', fontSize)
ylabel('Count Rate', 'FontSize', fontSize)
댓글 수: 5
Image Analyst
2023년 2월 13일
You forgot to attach 'data01.txt' so I can't run your code.
Line 9 is
title('X-ray detection events')
and would not throw that error because nothing is being indexed, unless you have called some variable "title" in some other script and it's still hanging around in the base workspace. Try calling
clear all
as the first line of your script to get rid of any prior variables you don't need.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
