Filter löschen
Filter löschen

How to have linear regression data appear on figure as text?

1 Ansicht (letzte 30 Tage)
DrWooo
DrWooo am 30 Okt. 2017
Bearbeitet: DrWooo am 30 Okt. 2017
Hello,
I'd like to have some linear regression data appear on a figure.
Currently, the code appear as:
for x = B(1:19,5)
for y = B(1:19,12);
figure(1);
subplot(3,1,1);
scatter(x,y); grid on;
hold on
lsline
mdl = fitlm(x,y);
str1 = 'r^2 = 0.800'; %This is found by looking at the output in the command window and manually entering the value back in
text(20,250,str1); %Manually entered text location, but would be happy with it appearing elsewhere
end
end
I would like both the r^2 value and the equation of the line to appear on the figure.
Any guidance or suggestions are greatly appreciated.
Cheers

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by