Applying text with variable on a plot
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daeyeon Koh
el 28 de Oct. de 2021
Respondida: Ive J
el 28 de Oct. de 2021
Hi. I drew a trend line in the plot and want to apply text
"R^2= Rsq1", where Rsq1 is a value got from calculation.
The figure attached shows the plot and text from my code (undesirable repeat of R^2=).
How can I apply test of "R^2= 99.5" when Rsq1=99.5?
p1 = polyfit(E1(:,3),E1(:,1),1);
yfit1 = polyval(p1, E1(:,3));
X1=-0.05:0.05:0.55;
Y1=p1(1)*X1+p1(2);
SStot1 = sum((E1(:,1)-E1(:,3)).^2);
SSres1 = sum((E1(:,1)-yfit1).^2);
Rsq1 = 1-SSres1/SStot1;
hold on
plot(X1,Y1);
txt = 'R^2 =';
text(X1,Y1,txt)
0 comentarios
Respuesta aceptada
Ive J
el 28 de Oct. de 2021
I don't have your dataset but you can follow this example:
plot(3:10, (6:13).^2, 'k.-', 'LineWidth', 1.5)
Rsq = 0.64645;
h = gca;
pos = [h.XLim(1) + 0.1*diff(h.XLim), h.YLim(2) - 0.1*diff(h.YLim)]; % top left corner
text(pos(1), pos(2), compose("R^2 = %.2f", Rsq))
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!