vertical lines of 'mean' and 'std' in a 'ksdensity' plot?

조회 수: 3 (최근 30일)
Fercho_Sala
Fercho_Sala 2021년 5월 31일
댓글: Fercho_Sala 2021년 6월 1일
Hello everyone. I was wondering how can I add vertical lines of standard deviation, mean, median , among other statistical results to a plot made with the function ‘ksdensity’ ? thank you.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 5월 31일
Use xline.
% create a distribution with known mean, std
pd = makedist('Normal','mu',2.5,'sigma',3.1);
x = random(pd,100,1);
[f,xi] = ksdensity(x);
figure
plot(xi,f);
% Add vertical lines
xline(2.5)
xline(2.5+[-3.1,3.1])
  댓글 수: 3
Cris LaPierre
Cris LaPierre 2021년 5월 31일
Calculate it.
mn = mean(x,'omitnan')
Fercho_Sala
Fercho_Sala 2021년 6월 1일
@Cris LaPierre how can I display the value of that 'mean' in the left, right side of the line? the x axis? , thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by