IF you're working on a one-off case, use the in-built tools:
Once you're happy with the plot settings, you can always get Matlab to generate the code of the plot for you - this way you can learn how certain things get done and develop your own code, which will be more human-friendly:
But if you're working on a re-usable code, read these:
And check out the code below:
clear all;
clc;
x = 1:20;
y = randn(1,20);
figure
plot(x,y,'bo');
hold on;
CFcoeff = polyfit(x,y,1);
xLimits = xlim;
xCF = linspace(xLimits(1),xLimits(2),50);
yCF = polyval(CFcoeff,xCF);
plot(xCF,yCF,'r-');
equationText = ['y = ' sprintf('%.2f',CFcoeff(1)) 'x' sprintf('%+.2f',CFcoeff(2))];
text(x(1), yCF(1)+0.2,equationText,...
'Color','r');