How can I show the correation coefficient R in the figure plot?

조회 수: 5 (최근 30일)
Ankita Kule
Ankita Kule 2017년 12월 25일
편집: Star Strider 2017년 12월 25일
I want to show the correlation coefficient value i.e R in the figure plot. I have used [R,P,RL,RU] = corrcoef(___) command, then I used scatter plot command. Using figure plot tool, I have done basic fitting but the problem is I am not able to show R-value in figure plot. Please help me.

답변 (1개)

Star Strider
Star Strider 2017년 12월 25일
편집: Star Strider 2017년 12월 25일
Use a text (link) object. Choose the (x,y) coordinates where you want it to appear, then after you plot your data:
text(x, y, sprintf('R = %.2f', R))
Experiment to get the result you want.
EDIT To add your ‘R’ value to a legend entry:
R_1 = 0.42;
R_2 = 0.21;
figure(1)
plot(rand(1,20), rand(1,20), 'pg', rand(1,20), rand(1,20), 'pr')
legend(sprintf('Data_1 (R = %.2f)',R_1), sprintf('Data_2 (R = %.2f)',R_2))

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by