Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
display r-squared value on plot?

Subject: display r-squared value on plot?

From: J G

Date: 6 Apr, 2011 05:31:04

Message: 1 of 3

I have a 5x5 subplot of scatter plots, each with a "trend line" and I would like to display the R-squared value on each of the subplots. Here is my code for just one of the subplots:

p = polyfit(v11,v21,1);
lin1 = polyval(p,v11);
subplot(5,5,1)
scatter(v11,v21,0.5,'black.')
hold on
plot(v11,lin1,'r')

Does anyone know how I can now display the R squared value of the polyfit line?
Thanks.

Subject: display r-squared value on plot?

From: Husam Aldahiyat

Date: 6 Apr, 2011 08:04:04

Message: 2 of 3

"J G" wrote in message <ingtqo$r50$1@fred.mathworks.com>...
> I have a 5x5 subplot of scatter plots, each with a "trend line" and I would like to display the R-squared value on each of the subplots. Here is my code for just one of the subplots:
>
> p = polyfit(v11,v21,1);
> lin1 = polyval(p,v11);
> subplot(5,5,1)
> scatter(v11,v21,0.5,'black.')
> hold on
> plot(v11,lin1,'r')
>
> Does anyone know how I can now display the R squared value of the polyfit line?
> Thanks.

title(['r^2 = ', var])

Subject: display r-squared value on plot?

From: ImageAnalyst

Date: 6 Apr, 2011 10:50:30

Message: 3 of 3

On Apr 6, 1:31 am, "J G" <jemma.geoghe...@gmail.com> wrote:
> Does anyone know how I can now display the R squared value of the polyfit line?
> Thanks.
-------------------------------------------------------
Try using text(). The sprintf() function will also be useful.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us