Clear Filters
Clear Filters

How to display correlation coefficents on plot?

2 views (last 30 days)
x = [0 0.000009 0.000018 0.000028 0.000037 0.000046 0.000055 0.000065 0.000074 0.000083 0.000092 0.000102];
y = [0 0.200 .300 .600 .900 1.20 1.50 1.80 2.10 2.40 2.70 3];
err = [0 0.011 0.0176 0.035 0.053 0.077 0.08 0.105 0.123 0.14 0.159 0.1766];
errorbar(x,y,err)
Im trying to add the correlation coefficent to my plot. Is there a way to simply add this to display it on the graph?

Answers (1)

Rafael Hernandez-Walls
Rafael Hernandez-Walls on 5 May 2021
you can try something like this:
x = [0 0.000009 0.000018 0.000028 0.000037 0.000046 0.000055 0.000065 0.000074 0.000083 0.000092 0.000102];
y = [0 0.200 .300 .600 .900 1.20 1.50 1.80 2.10 2.40 2.70 3];
err = [0 0.011 0.0176 0.035 0.053 0.077 0.08 0.105 0.123 0.14 0.159 0.1766];
errorbar(x,y,err)
CCR= corrcoef([x' y'])
text(0.00004,3,['Coef correlation= ' num2str(CCR(2,1))])

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!